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

Circular dependency error while just importing ScheduleModule inside AppModule #52

Closed
gheiler-on opened this issue Jan 28, 2020 · 1 comment

Comments

@gheiler-on
Copy link

I'm submitting a...


[ ] Regression 
[ x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When trying to import the ScheduleModule, then I receive a circular dependency error while server is initializing

Error: Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it. 
(Read more: https://docs.nestjs.com/fundamentals/circular-dependency)
Scope [AppModule -> ]

Expected behavior

Importing the ScheduleModule shouldn't produce a circular dependency problem

Minimal reproduction of the problem with instructions

@Module({
  imports: [
    HttpModule,
    TypeOrmModule.forRoot({
      aConfig
    }),
    CacheModule.register(),
    SomeMoreModulesOfMyOwn,
    ScheduleModule.forRoot()
  ],
  controllers: [
    AppController
  ]
})
export class AppModule implements NestModule {
  constructor() {
  }

  configure(consumer: MiddlewareConsumer) {
    if (process.env.log_requests === 'true') {
      consumer
        .apply(LoggerMiddleware)
        .forRoutes({ path: '*', method: RequestMethod.ALL });
    }
  }
}

What is the motivation / use case for changing the behavior?

fix a bug

Environment


Nest version: 6.10.5

 
For Tooling issues:
- Node version: 10.16.3  
- Platform:  Mac

Others:

@gheiler-on
Copy link
Author

gheiler-on commented Jan 28, 2020

sorry my bad, closed here #7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant