본문 바로가기
프로그래밍/JavaScript

npm install 시 Could not resolve dependency: 오류가 해결방법

by 공부하는EJ 2022. 6. 29.
728x90

 

💡 오류 해결 방법

 

react-redux를 설치하려고 하닌 dependency 에러가 발생했다.

 

(base)  eunjaeyoon@Eunjaeui-iMac  ~/Desktop/CodingApple/shop   master ±  npm install @reduxjs/toolkit react-redux
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: shop@0.1.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   peer react@">=16.8.0" from @restart/hooks@0.4.7
npm ERR!   node_modules/@restart/hooks
npm ERR!     @restart/hooks@"^0.4.0" from @restart/ui@1.2.0
npm ERR!     node_modules/@restart/ui
npm ERR!       @restart/ui@"^1.2.0" from react-bootstrap@2.4.0
npm ERR!       node_modules/react-bootstrap
npm ERR!         react-bootstrap@"^2.4.0" from the root project
npm ERR!     @restart/hooks@"^0.4.6" from react-bootstrap@2.4.0
npm ERR!     node_modules/react-bootstrap
npm ERR!       react-bootstrap@"^2.4.0" from the root project
npm ERR!   peer react@">=16.14.0" from @restart/ui@1.2.0
npm ERR!   node_modules/@restart/ui
npm ERR!     @restart/ui@"^1.2.0" from react-bootstrap@2.4.0
npm ERR!     node_modules/react-bootstrap
npm ERR!       react-bootstrap@"^2.4.0" from the root project
npm ERR!   11 more (@testing-library/react, prop-types-extra, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! @reduxjs/toolkit@"*" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"^18.2.0" from react-dom@18.2.0
npm ERR!   node_modules/react-dom
npm ERR!     react-dom@"^18.1.0" from the root project
npm ERR!     peerOptional react-dom@"^16.8 || ^17.0 || ^18.0" from react-redux@8.0.2
npm ERR!     node_modules/react-redux
npm ERR!       react-redux@"*" from the root project
npm ERR!       1 more (@reduxjs/toolkit)
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 /Users/eunjaeyoon/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/eunjaeyoon/.npm/_logs/2022-06-28T22_48_10_048Z-debug-0.log

 

에러에 확인해보면 --force 혹은 --legacy-peer-deps 랑 같이 다시 시도해보라고 쓰여 있다.

나는 force에 대한 안 좋은 기억이 많아서 --legacy-peer-deps을 끝에 붙여서 해결!

this command with --force, or --legacy-peer-dep

 

npm install @reduxjs/toolkit react-redux --save --legacy-peer-deps
728x90

댓글