Is there an existing issue for this?
There is an existing issue #3171 which looks similar. Even though it's marked as resolved, I still have this problem.
This issue exists in the latest npm version
Current Behavior
npm install fails to resolve two version ranges of one dependency into a version that is compatible with both requirements.
When I try to add another package to a project with "react": "^16.9.0" I get a conflict, even though the ranges are compatible (peerDependencies of the package being installed is "react": "^0.14.9 || >=15.3.0").
It looks like npm first independently resolves both ranges to the latest possible version that satisfies the requirements and then checks if they are compatible.
Expected Behavior
npm should check if the already installed dependency version satisfies the required peerDependency range in the package being installed.
Steps To Reproduce
mkdir peer-dependency-conflict-demo
cd peer-dependency-conflict-demo
npm add react@^16.9.0
npm add react-bootstrap@=0.32.4
npm ERR! code ERESOLVE
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR! react@"^16.14.0" from the root project
npm ERR! peer react@"^0.14.9 || >=15.3.0" from react-bootstrap@0.32.4
npm ERR! node_modules/react-bootstrap
npm ERR! react-bootstrap@"=0.32.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from react-dom@17.0.2
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^0.14.9 || >=15.3.0" from react-bootstrap@0.32.4
npm ERR! node_modules/react-bootstrap
npm ERR! react-bootstrap@"=0.32.4" 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 /home/ivan/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ivan/.npm/_logs/2021-11-17T15_45_03_518Z-debug.log
Environment
- npm: v16.13.0
- Node: v8.1.4
- OS: Fedora Linux 35, Kernel 5.15.3
- platform: Asus ROG Zephyrus G14
- npm config:
; "user" config from /home/ivan/.npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /home/ivan/.nvm/versions/node/v16.13.0/bin/node
; cwd = /home/ivan/workspace/sandbox/peer-dependency-conflict-demo
; HOME = /home/ivan
; Run `npm config ls -l` to show all defaults.
Is there an existing issue for this?
There is an existing issue #3171 which looks similar. Even though it's marked as resolved, I still have this problem.
This issue exists in the latest npm version
Current Behavior
npm installfails to resolve two version ranges of one dependency into a version that is compatible with both requirements.When I try to add another package to a project with
"react": "^16.9.0"I get a conflict, even though the ranges are compatible (peerDependenciesof the package being installed is"react": "^0.14.9 || >=15.3.0").It looks like
npmfirst independently resolves both ranges to the latest possible version that satisfies the requirements and then checks if they are compatible.Expected Behavior
npmshould check if the already installed dependency version satisfies the requiredpeerDependencyrange in the package being installed.Steps To Reproduce
mkdir peer-dependency-conflict-demo cd peer-dependency-conflict-demo npm add react@^16.9.0 npm add react-bootstrap@=0.32.4npm ERR! code ERESOLVE
react-bootstrappackage.json: https://github.com/react-bootstrap/react-bootstrap/blob/v0.32.4/package.json#L54-L57Environment