nest start시 __dirname 경로 문제

정민교·2024년 5월 20일
0

trouble shooting

목록 보기
5/5

📒문제

typeomr 연결 설정으로 entity 경로 설정 시 entity를 찾지 못하는 문제

✔️문제 상황

    const entitiesPath = path.join(process.cwd() + '/**/*.entity.{ts,js}');
    
    entities: [entitiesPath],

entity의 경로를 적어주었는데, entity 경로를 파악하지 못함.

__dirname 을 콘솔에 출력한 결과 현재 경로가 프로젝트 루트의 dist 폴더 안으로 출력되고 있었음

📒해결

__dirname의 경로가 프로젝트 루트의 dist 경로로 포함되어서 나와서

    const entitiesPath = path.join(process.cwd() + '/dist/**/*.entity.{ts,js}');

경로에 /dist를 추가하고 해결되었음.

현재경로가 왜 dist로 시작되는지 모르겠지만, nest start 명령어로 프로젝트 실행 시 dist 경로에서 이루어지는 듯 함

profile
백엔드 개발자

0개의 댓글