I'm confused by the error referred to by nestjs, the full error is like this
Error: Nest cannot create the AuthModule instance.
The module at index [5] of the AuthModule "imports" array is undefined.
Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
- The module at index [5] is of type "undefined". Check your import statements and the type of the module
Scope [AppModule -> AuthModule -> UsersModule]
AppModule
// Import
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
...
}),
AuthModule,
UsersModule,
],
})
export class AppModule {}
AuthModule
// Import
@Module({
imports: [
...
forwardRef(() => UsersModule),
],
controllers: [AuthController],
providers: [AuthService, JwtStrategy],
exports: [AuthService],
})
export class AuthModule {}
UsersModule
// Import Module
@Module({
imports: [
...
forwardRef(() => AuthModule),
],
controllers: [UsersController],
providers: [UsersService],
exports: [UsersService],
})
export class UsersModule {}
Even though the code already applies forwardRef, can anyone help?