-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] Multiple related packages install fail due to wrong peerDependencies resolution #3083
Comments
Based on my debugging of this issue for Renovate, I found:
|
I think I'm seeing roughly this same behavior with |
Here's another example, installing npm ERR! While resolving: app@0.0.1
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR! peer react@"*" from react-navigation@4.4.4
npm ERR! node_modules/react-navigation
npm ERR! react-navigation@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from react-native@0.64.0
npm ERR! node_modules/react-native
npm ERR! peer react-native@"*" from react-navigation@4.4.4
npm ERR! node_modules/react-navigation
npm ERR! react-navigation@"*" from the root project The exact same issue happens with many other packages in the React Native ecosystem - for example callstack/react-native-paper#2603. What's going on here as I read it:
NPM sees this as a conflict and crashes. I think this is a bug because all deps can be satisfied with Looks like the open PR npm/arborist#266 should solve this, thanks. |
why is this closed? It's still active in 8.11.0 |
@leonheess follow this issue #3666 |
Current Behavior:
When having multiple packages relying on each others having the exact same version, trying to update them all via
npm install
fails when there is another package which loosely rely on them via"peerDependencies": "^x.x.x"
, due to npm7 erroneous resolution.Real world example: Angular core packages are supposed to be installed with the exact same version, so for example
@angular/common@11.2.9
has"peerDependencies": { "angular/core": "11.2.9" }
(note the exact version).Until now everything is fine. You can update all versions to
11.2.10
inpackage.json
, runnpm install
and it works.But now add another package which relies on one of the core packages, for example
@angular-devkit/build-angular@11.2.9
has a"peerDependencies": { "@angular/compiler-cli": "^11.0.0 || ^12.0.0-next" }
.Now if you update all versions to
11.2.10
inpackage.json
and runnpm install
, it fails.Expected Behavior:
npm install
should work, as versions are correct andpeerDependencies
are respected.Steps To Reproduce:
Working:
mkdir npmissue
cd npmissue
npm init -y
npm install @angular/common@11.2.9 @angular/compiler@11.2.9 @angular/core@11.2.9 @angular/platform-browser@11.2.9 @angular/platform-browser-dynamic@11.2.9 -E
npm install @angular/compiler-cli@11.2.9 -D -E
11.2.9
>11.2.10
inpackage.json
npm install
: OKFailing:
npm install @angular-devkit/build-angular@11 -D -E
11.2.9
>11.2.10
inpackage.json
npm install
: fails withpeerDependencies
errorsnpm log
Environment:
Additional information:
This issue was raised because it causes issues in automatic dependencies update tools like Renovate, which are doing exactly what I described: updating the
package.json
and then doing anpm install
.See renovatebot/renovate#9561 for the Renovate issue, and cyrilletuzi/angular-async-local-storage#628 for a real world example, with npm logs.
Additional debug info:
Doing
rm -rf node_modules && rm package-lock.json
, thennpm install
works without errors or warnings.Or doing
npm install --force
, thennpm install
has no more errors.Meaning the
peerDependencies
are indeed respected and it should work in the first place. Seems like the presence ofpackage-lock.json
and/ornode_modules
results in an issue in correct dependencies resolution.The text was updated successfully, but these errors were encountered: