I build NestJS projecct with many modules and recently I got lost in them a bit, My last thing which I'm doing was added QueueService to my ProjectService and ProjectModule, but after launch whole app, the compiler throw me this:
Error: Nest can't resolve dependencies of the QueueService (UtilsService, UserService, Connection, ?). Please make sure that the argument Object at index [3] is available in the ProjectModule context.
The argument at the index[3] at QueueService is ProjectService, so why they want from me to import ProjectModule/ProjectService into my ProjectModule? :P
here is my all code:
@Injectable()
export class ProjectService {
constructor(
private conn: Connection,
private utilsService: UtilsService,
private userService: UserService,
private notificationService: NotificationsService,
private queueService: QueueService
) { }
@Module({
imports: [
PassportModule.register({ defaultStrategy: 'jwt'})
],
providers: [ProjectService, UtilsService, UserService, NotificationsService, QueueService ],
controllers: [ProjectController],
exports: [ProjectService]
})
export class ProjectModule {}
@Injectable()
export class QueueService {
constructor(
readonly conn: Connection,
readonly utilsService: UtilsService,
readonly userService: UserService,
readonly projectService: ProjectService
){}
}
@Module({
imports: [
AuthModule,
PassportModule.register({ defaultStrategy: 'jwt'})],
providers: [QueueService , UtilsService, UserService, NotificationsService, ProjectService],
controllers: [QueueController ],
exports: [PassportModule]
})
export class QueueModule {}
AppModule
@Module({
imports: [
...,
TypeOrmModule.forRootAsync({
useClass: TypeOrmConfigService
}),
PassportModule.register({ defaultStrategy: 'jwt'}),
JwtModule.register({
secret: 'secretKey'
}),
ScheduleModule.forRoot(),
...,
...,
QueueModule,
...,
...,
ProjectModule,
...,
...,
...
],
controllers: [..., ..., ..., ..., ...],
providers: [ ..., ..., ..., ..., ...,ProjectService, ..., ..., QueueService],
})
export class AppModule {}
thanks for any help, I stuck here for 3-4h and I do not know what can I do more :(
////////////////////////////////////