-
2023 - 08 - 19 에러핸들링: Nest can't resolve dependencies of the ChallengesRepository 의존성 주입, 역전제어Today I Learned/TIL 08 2023. 8. 19. 21:28
Nest can't resolve dependencies of the ChallengesRepository (DataSource, ?). Please make sure that the argument Object at index [1] is available in the ChallengeModule context. Potential solutions: - Is ChallengeModule a valid NestJS module? - If Object is a provider, is it part of the current ChallengeModule? - If Object is exported from a separate @Module, is that module imported within ChallengeModule? @Module({ imports: [ /* the Module containing Object */ ] })
Nest.js TypeORM 서버 실행시 위와 같은 오류가 계속 발생했다.
여기서, constructor 생성자 안에 있는 인스턴스 logger를 new로 새로 생성해서는 안된다. constructor안에 넣는 것 자체가 의존성을 주입하는 것인데, new로 선언할수는 없다. 이를 역전제어라고 한다.
그래서 다음과 같이 바꾸었더니 서버가 실행되었다.
'Today I Learned > TIL 08' 카테고리의 다른 글