[ NestJS ] 동적 모듈 사용 시에 환경 변수 파일이 복사가 되지 않는 문제

jwkwon0817·2024년 7월 25일
0

Web Back-end

목록 보기
23/26
post-thumbnail

NestJS를 사용할 때 주로 dotenv보다 @nestjs/config를 사용하여 환경변수를 관리하는 경우가 많습니다.

이 경우에 AppModule에서 동적 모듈을 사용해야하는데 이 때 nest start --watch로 하게 된다면 아래 nset-cli.json에서 assets 부분이 적용되지 않을 수 있습니다.

nest-cli.json

{
  ...
  "compilerOptions": {
    ...
    "assets": [
      {
        "include": "./config/env/*.env",
        "outDir": "./dist"
      }
    ],
  }
}

이 부분을 아래와 같이 고치면 nest start --watch로 프로그램을 실행해도 정상적으로 동작하는 것을 볼 수 있습니다.

nest-cli.json

{
  ...
  "compilerOptions": {
    ...
    "assets": [
      {
        "include": "./config/env/*.env",
        "outDir": "./dist"
      }
    ],
	"watchAssets": true,
  }
}
profile
SRIHS 119th SW

0개의 댓글