250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

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:54
728x90

오류

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