-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[BUG] npm install
fails to resolve compatible peerDependencies requirements
#4104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I confirm there also is an error when peerDependencies of the package being installed is "react": "^16.0.0 || ^17.0.0" (and the root package has react@^16.9.0 as in the example above). Since [email protected] matches react ^16.0.0 there should be no error. Using Summary> npm i @carbon/[email protected]
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^16.14.0" from the root project
npm ERR! peer react@"^16.0.0 || ^17.0.0" from @carbon/[email protected]
npm ERR! node_modules/@carbon/charts-react
npm ERR! @carbon/charts-react@"0.53.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.2" from [email protected]
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^16.0.0 || ^17.0.0" from @carbon/[email protected]
npm ERR! node_modules/@carbon/charts-react
npm ERR! @carbon/charts-react@"0.53.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 /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
... |
Any news about this issue, please? I have probably the same issue. My package has peer dependency for When I try to install any package that has peer dependencies for react and react-dom specified like this
(allowing version 16 and 17) . NPM is trying to resolve the highest react-dom version possible since I am not specifying it in my package peer dependencies (or any other dependencies) and this package allows react-dom@17 (and 16). I do not know if this is intended functionality, but in my opinion, NPM should try to resolve react-dom compatible with the dependencies I specified and that is react@16 so it should try to resolve react-dom@16. Of course, everything gets resolved correctly when I add react-dom in my peer dependencies (or any other dependencies). |
Latest v8.4.0 sadly still with the same issue. You can use |
@christek you always have to include @e1himself your issue is caused by having This is just how it's done in the react ecosystem, due to the way react has set up all their dependency/peerDep relationships. |
@ljharb I'm confused with your comment. Please see the reproduction steps in the issue description. There is no dependency requiring React 17. It's a bug of npm being unable to properly resolve an intersection of two version requirements. |
But installing mkdir peer-dependency-conflict-demo
cd peer-dependency-conflict-demo
npm add react@^16 react-dom@^16
npm add react-bootstrap@=0.32.4 |
@e1himself yes, i understand that npm is selecting react-dom 17, and that creates the incompatibility. But, in the react ecosystem, you always, without exception have to explicitly specify react-dom, even if npm were to fix this. |
Thanks for your input @ljharb 👍 Requiring I will check if this trick will work for my actual production app and comment here later. Thanks! |
I don't seem to be able to reproduce the issue anymore. Thanks to the suggestion @ljharb made above. Closing. Thanks everyone 🙇 |
Uh oh!
There was an error while loading. Please reload this page.
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 requiredpeerDependency
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
react-bootstrap
package.json: https://github.com/react-bootstrap/react-bootstrap/blob/v0.32.4/package.json#L54-L57Environment
The text was updated successfully, but these errors were encountered: