nest.js 에러: constructor 에 받아온 모듈이 this로 읽히지가 않음

리린·2021년 9월 2일
0

Nest.js

목록 보기
5/10

문제상황

export class MoviesController {
  constructor(private readonly moviesService: MoviesService) {}
  @Get()
  getAll(): Movie[] {
    return this.moviesService.getAll();
  }
  ..
  

여기서 자꾸 에러가 난다.

원인

  • 이것저것 삭제해보기도 하고 설정 만지다 보니 nest.js 설정이 제대로 되지 않았음을 알게 됨
  • nest.js 권장 설정
{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  }
}

해결방법

tsconfig.json에 가서

"emitDecoratorMetadata": true 속성을 true로 설정한다

참고 블로그

https://m.blog.naver.com/pjt3591oo/222120496022

profile
개발자지망생

0개의 댓글