제가 보기에는 의존성을 모두 걸어줬는데도 아래와 같은 에러가 발생했습니다.
Error: Nest can't resolve dependencies of the ChatController (DataSource, ?). Please make sure that the argument ChatService at index [1] is available in the AppModule context.
Potential solutions:
- Is AppModule a valid NestJS module?
- If ChatService is a provider, is it part of the current AppModule?
- If ChatService is exported from a separate @Module, is that module imported within AppModule?
@Module({
imports: [ /* the Module containing ChatService */ ]
})
at Injector.lookupComponentInParentModules (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:254:19)
at Injector.resolveComponentInstance (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:207:33)
at resolveParam (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:128:38)
at async Promise.all (index 1)
at Injector.resolveConstructorParams (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:143:27)
at Injector.loadInstance (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:70:13)
at Injector.loadController (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/injector.js:88:9)
at /home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/instance-loader.js:68:13
at async Promise.all (index 3)
at InstanceLoader.createInstancesOfControllers (/home/kyc/work/iipuda-server/node_modules/@nestjs/core/injector/instance-loader.js:67:9)
AppModule에 ChatService가 없다고 나오는데, ChatService를 ChatModule에 의존성 주입하고, ChatModule을 AppModule에 의존성 주입을 했다면 일반적으로는 문제가 없어야 합니다만 어째서 이런 에러를 발생 시켰을 까요..
중복 주입으로 인한 문제인것 같습니다.
app.module.ts
기존의 의존성을 모두 제거하고 빈상태로 만듭니다.
chat.module.ts
*.controller.ts에서 AuthGuard를 사용 중이기 때문에 관련 service를 provider에 주입합니다.