-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 #3171
Comments
i'm not able to reproduce this as without that package installed i had no issues with following the rest of your steps. i'm not sure how that command is installing anything for you at all, do you have a separate registry configured? |
@nlf Sorry, it was just an error in the reproduction step. This package has a different version management indeed, I have updated the initial message with the correct instructions. |
no problem! that got the reproduction working, thanks for making it clear 👍 |
hi, |
Closing this issue as it's now resolved (tested with npm 7.20.3, but I think it was already fixed since a few minor versions). |
@cyrilletuzi it still happens to me using 7.24.2 |
I still have this issue with npm Steps to reproducemkdir peer-dependency-conflict-demo
cd peer-dependency-conflict-demo
npm add react@^16.9.0
npm add react-bootstrap@=0.32.4 Expected BehaviorNPM installs the requested package, knowing that the current installed version of Actual Behavior
UPD: I was not sure if it's the same issue, or a different one. Filed a new ticket: #4104. |
Reopening #3083, given that npm/arborist#266 and npm/arborist#272 didn't fix the issue.
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@0.1102.9 -D -E
11.2.9
>11.2.10
and0.1102.9
>0.1102.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: