인프런 커뮤니티 질문&답변
제로초님 imports 모듈에러가 나서 질문드려요
해결된 질문
작성
·
263
1
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Shops } from 'src/entities/shops.entity';
import { ShopsController } from './shops.controller';
import { ShopsService } from './shops.service';
@Module({
imports: [TypeOrmModule.forFeature([Shops])],
controllers: [ShopsController],
providers: [ShopsService],
})
export class ShopsModule {}
이렇게 작성을 하였는데
webpack 5.72.1 compiled successfully in 137 ms [Nest] 10891 - 2022. 06. 23. 오후 6:55:30 LOG [NestFactory] Starting Nest application... [Nest] 10891 - 2022. 06. 23. 오후 6:55:30 LOG [InstanceLoader] TypeOrmModule dependencies initialized +38ms [Nest] 10891 - 2022. 06. 23. 오후 6:55:30 LOG [InstanceLoader] PassportModule dependencies initialized +0ms [Nest] 10891 - 2022. 06. 23. 오후 6:55:30 ERROR [ExceptionHandler] Nest can't resolve dependencies of the ShopsService (ShopsRepository, ?). Please make sure that the argument UsersRepository at index [1] is available in the ShopsModule context. Potential solutions: - If UsersRepository is a provider, is it part of the current ShopsModule? - If UsersRepository is exported from a separate @Module, is that module imported within ShopsModule? @Module({ imports: [ /* the Module containing UsersRepository */ ] }) 이렇게 에러가 나네요.. 도저히 모르겠어서 질문드립니다.
답변 2
1
1
제가 제로초님은 아니지만 귀뜸 하나 해드리면 혹시 ShopsService를 UserRepository에서 사용하시나요? 그리고 Shops 모듈내에서 ShopsRepository가 사용되시나요? 만약 ShopsRepository가 사용된다면 provider에 ShopsRepository를 넣어주세요.
Shops 모듈에서 다른 모듈로 provider를 제공해 주려면 exports 배열을 만든 후 ShopsService를 넣어주세요.
그리고 다른 모듈(UserModule)에가서 imports에 ShopModule을 넣어주세요.





