ERROR 내용
Error: Nest can't resolve dependencies of the BlockService (?). Please make sure that the argument TBlockModel at index [0] is available in the AppModule context.
Potential solutions:
- Is AppModule a valid NestJS module?
- If TBlockModel is a provider, is it part of the current AppModule?
- If TBlockModel is exported from a separate @Module, is that module imported within AppModule?
@Module({
imports: [ /* the Module containing TBlockModel */ ]
})
해결
app.module.ts
@Module({
imports: [
BoardsModule,
BlockModule,
MongooseModule.forRoot('mongodb://localhost:27017'),
],
controllers: [AppController, BlockController],
providers: [AppService, BlockService],
})
export class AppModule {}
여기가 문제였다.
imports안에 이미 BlockModule이 추가되어 있으므로, controllers와 providers에는 BlockController와 BlockService를 추가할 필요가 없다.
따라서 제거해주면 해결 끝!