What / Why
npm install fails to resolve two version ranges of one dependency into a version that is compatible with both requirements.
I have to use the unsafe --legacy-peer-deps flag to bypass this error.
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").
How
Current Behavior
When resolving peer dependencies, npm picks the latest available edge version of react compatible with the installed peerDependency requirements, which is 17.0.2 at the moment, ignoring the rest of the range. And then fails with dependency version conflict.
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
Expected Behavior
NPM installs the requested package, knowing that the current installed version of react is compatible with its peer requirements ("react": "16.14.0" satisfies ^0.14.9 || >=15.3.0).
References
https://github.com/react-bootstrap/react-bootstrap/blob/v0.32.4/package.json#L54-L57
What / Why
npm installfails to resolve two version ranges of one dependency into a version that is compatible with both requirements.I have to use the unsafe
--legacy-peer-depsflag to bypass this error.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").How
Current Behavior
When resolving peer dependencies,
npmpicks the latest available edge version ofreactcompatible with the installedpeerDependencyrequirements, which is17.0.2at the moment, ignoring the rest of the range. And then fails with dependency version conflict.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
Expected Behavior
NPM installs the requested package, knowing that the current installed version of
reactis compatible with its peer requirements ("react": "16.14.0"satisfies^0.14.9 || >=15.3.0).References
https://github.com/react-bootstrap/react-bootstrap/blob/v0.32.4/package.json#L54-L57