Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example not working for me #11

Closed
Mirokko opened this issue Feb 13, 2018 · 3 comments
Closed

Example not working for me #11

Mirokko opened this issue Feb 13, 2018 · 3 comments
Labels

Comments

@Mirokko
Copy link

Mirokko commented Feb 13, 2018

I have following code:

import {
  Module,
  MiddlewaresConsumer,
  NestModule,
  RequestMethod,
} from '@nestjs/common';
import { graphqlExpress } from 'apollo-server-express';
import { GraphQLModule, GraphQLFactory } from '@nestjs/graphql';
import {UsersModule} from './Users/users.module';

@Module({
  imports: [GraphQLModule],
  modules: [UsersModule],
export class ApplicationModule {
  constructor(private readonly graphQLFactory: GraphQLFactory) {}
}

And application exits with following error:

[Nest] 24011   - 2018-2-13 13:06:05   [NestFactory] Starting Nest application...
[Nest] 24011   - 2018-2-13 13:06:05   [ExceptionHandler] Nest can't resolve dependencies of the ApplicationModule (?). Please verify whether [0] argument is available in the current context.
Error: Nest can't resolve dependencies of the ApplicationModule (?). Please verify whether [0] argument is available in the current context.
    at Injector.<anonymous> (/home/tymur/Learning/nest/project/node_modules/@nestjs/core/injector/injector.js:160:23)
    at Generator.next (<anonymous>)
    at fulfilled (/home/tymur/Learning/nest/project/node_modules/@nestjs/core/injector/injector.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:190:16)
    at bootstrap_node.js:662:3
 1: node::Abort() [node]
 2: 0x8c8099 [node]
 3: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 4: 0xaddc5c [node]
 5: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 6: 0x3ab9ebd042fd
Aborted (core dumped)

UsersModule is dummy module:

import {Module} from '@nestjs/common';
import {UsersService} from './users.service';
import UsersController from './users.controller';
import {usersProviders} from './users.providers';
import {DatabaseModule} from '../common/database/database.module';
import {LibrariesModule} from '../Libraries/libraries.module';
import {UserResolver} from './user.resolver';

@Module({
  // modules: [DatabaseModule, LibrariesModule],
  // controllers: [UsersController],
  // components: [
  //   UsersService,
  //   ...usersProviders,
  //   UsersResolver,
  // ],
  // exports: [
  //   UsersService,
  // ],
})
export class UsersModule {}

but if i comment out modules: [UsersModule], in ApplicationModule, everithing works fine. Same as commenting out constructor in application module. What im doing wrong?

@kamilmysliwiec
Copy link
Member

Hi @ToKaTpoHb,
You can't use modules and imports property at the same time. They're equal, just use imports.

@Mirokko
Copy link
Author

Mirokko commented Mar 29, 2018

Thanks for the tip. Seems like it resolved my issue. And sorry for not telling this right away =)

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants