ERESOLVE unable to resolve dependency tree 에러 해결하기

wonjun.Aden·2022년 10월 14일
0

nestJs

목록 보기
2/5
post-thumbnail

nestjs와 뗴려야 뗼 수 없는 사이인 typeorm을 설치하다가 발생하는 에러에 대하여 적어보려 한다.
우선 현재 nestjs의 버전은 최신 버전은 (현재기준) 9.1.4 버전이다. 이 버전에서 typeorm을 설치하면 0.3.0 버전으로 설치가 된다. 하지만 나는 typeorm 0.2.x버전을 설치하길 원했다.
왜냐하면 typeorm의 @EntityRepository()를 사용해보기 위해서였다. typeorm의 0.3.x 버전에서는 @EntityRepository()를 지원하지 않아 대부분 커스텀데코레이터를 만들어 사용하고 있다. 0.3.x 버전과 0.2.x 버전의 차이를 알기 위하여 typeorm 0.2.38을 설치하려고 npm install 명령어를 실행하였다.

하지만!!!

나에게 돌아온 것은 에러뿐...

$ npm install typeorm@0.2.38 @nestjs/typeorm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: nestjs-without-typeorm@0.0.1
npm ERR! Found: typeorm@0.2.38
npm ERR! node_modules/typeorm
npm ERR!   typeorm@"0.2.38" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typeorm@"^0.3.0" from @nestjs/typeorm@9.0.1
npm ERR! node_modules/@nestjs/typeorm
npm ERR!   @nestjs/typeorm@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\wonjun1995\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\wonjun1995\AppData\Local\npm-cache\_logs\2022-10-14T01_29_44_984Z-debug-0.log

typeorm과 nestjs/typeorm의 의존성을 해결하지 못하고 있었다.
의존성을 해결하는 방법으로는 두가지를 추천해줬는데
강제로 설치하는 것과 peerDependencies를 무시하는 방법 이렇게 두가지가 있었다.
그 중에 나는 강제 설치 보단 peerDependencies를 무시하는 쪽으로 설정하였다.
설정방법은 아래와 같다.

npm install --legacy-peer-deps

이 명령어를 통하여 ERROR를 해결하였다.
추가적으로

npm config set legacy-peer-deps true

명령어도 있는데 이 명령어는 npm에서 권장하지 않는 방법이다. 모든 npm install을 legacy-peer-deps로 설정하기 때문이다.

이제 typeorm도 설치하였으니 다시 또 nestjs 버전 테스트를 하러 가보도록 하겠돠.

profile
아프리카의 BackEnd Developer 장원준입니다.

0개의 댓글