MSA
NestJS 마이크로서비스 설치 시 발생하는 의존성 충돌 해결하기
notcherry
2025. 2. 6. 11:05
728x90
반응형
npm i --save @nestjs/microservices
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: llm@0.0.1
npm error Found: @nestjs/common@10.4.15
npm error node_modules/@nestjs/common
npm error @nestjs/common@"^10.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @nestjs/common@"^11.0.0" from @nestjs/microservices@11.0.7
npm error node_modules/@nestjs/microservices
npm error @nestjs/microservices@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error Ct
npm error A complete log of this run can be found in: ,,,
npm i --save @nestjs/microservices , npm i 모두 안됐던 상황
원인 분석
이 에러가 발생하는 주된 이유는 버전 불일치 때문입니다:
- 현재 프로젝트에서는 @nestjs/common 10.4.15 버전을 사용 중
- 설치하려는 @nestjs/microservices 11.0.7 버전은 @nestjs/common 11.0.0 이상 버전을 필요로 함
- 이로 인해 의존성 트리를 해결할 수 없는 상황 발생
해결 방법
1. 동일 버전의 마이크로서비스 패키지 설치 (권장) -> 채택한 방법
npm i --save @nestjs/microservices@10.4.15
- 장점:
- 기존 프로젝트의 안정성 유지
- 호환성 문제 최소화
- 즉시 적용 가능
- 단점: 최신 기능 사용 불가
2. NestJS 전체 버전 업그레이드
npm update @nestjs/core @nestjs/common @nestjs/platform-express
npm i --save @nestjs/microservices
-장점:
- 최신 기능 사용 가능
- 보안 패치 적용
- 단점:
- Breaking Changes 가능성
- 기존 코드 수정 필요할 수 있음
- 추가 테스트 필요
3. 강제 설치 (비권장) -> 나는 이걸로도 해결이 안됨 ㅎ
npm i --save @nestjs/microservices --force
# 또는
npm i --save @nestjs/microservices --legacy-peer-deps
- 장점:
- 빠른 설치 가능
- 단점:
- 예상치 못한 버그 발생 가능
- 프로덕션 환경에서 문제 발생 위험
권장 사항
- 가능하면 동일한 메이저 버전을 사용하는 것을 권장
- 버전 업그레이드가 필요한 경우:
- 공식 문서의 마이그레이션 가이드 확인
- 단계적 업그레이드 진행
- 충분한 테스트 수행
728x90
반응형