devlog_owen
[TIL]Nest can't resolve dependencies of the StorebookService 오류 해결 본문
TIL
[TIL]Nest can't resolve dependencies of the StorebookService 오류 해결
developer_owen 2024. 1. 22. 23:54728x90
오류
ERROR [ExceptionHandler] Nest can't resolve dependencies of the StorebookService (?). Please make sure that the argument "StoreBookRepository" at index [0] is available in the StorebookModule context.
Potential solutions:
- Is StorebookModule a valid NestJS module?
- If "StoreBookRepository" is a provider, is it part of the current StorebookModule?
- If "StoreBookRepository" is exported from a separate @Module, is that module imported within StorebookModule?
@Module({
imports: [ /* the Module containing "StoreBookRepository" */ ]
})
진짜 단골오류.
해결
import { Module } from '@nestjs/common';
import { StorebookController } from './store-book.controller';
import { StorebookService } from './store-book.service';
import { StoreBook } from 'src/entity/store-book.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
@Module({
imports: [TypeOrmModule.forFeature([StoreBook])],
controllers: [StorebookController],
providers: [StorebookService],
})
export class StorebookModule {}
import에 storebook entity를 추가해주면 된다.
import는 다른 코드를 현재 코드로 가져오는 역할,
provider는 의존성을 제공하는 역할,
controllers는 프로그램의 흐름을 제어하고 요청에 따른 처리를 하는 역할,
exports는 다른 코드에서 현재 코드의 일부를 사용할 수 있게 하는 역할
728x90
'TIL' 카테고리의 다른 글
MySQL 배열로 데이터 저장하기 (+nest.js, swagger) (0) | 2024.03.05 |
---|---|
[TIL] Redis maxmemory 설정, LRU 캐시전략 설정하기 (0) | 2024.01.29 |
[TIL] .env 파일이 gitignore에 있는데도 푸시될때 해결법 (0) | 2024.01.19 |
[TIL] [기술면접] OAuth에 대해서 설명해주세요. (0) | 2024.01.18 |
[TIL] nest.js에서 네이버 소셜로그인 기능구현하기 (0) | 2024.01.18 |