-
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] npm ci can't resolve dependencies without --force, or --legacy-peer-deps #4998
Comments
This is a breaking change without bumping major version. Any update on this issue? |
Not sure if this is related. I have a package-lock file generated using npm 8.5.0 when I try to do a
Adding |
The bug (feature maybe?, but very annoying) exists since npm@8.6 (included). On npm@8.5 everything good |
I think this is the intended behaviour. The official doc states that:
|
If this is intended and breaks |
This doesn't "break" npm install; my assumption is that it was previously working in our use case because of a bug, which has now been fixed (can't see the official documentation history, so I'm not sure if it was also stated before) |
Before 8.6 I could run |
I believe you can with the following:
|
This is where my case is slightly different. Generated the lock-file without any special parameters, but adding the |
Did you try removing the lock file as well as the node modules and retrying? |
I've seen this behavior as well - but the puzzling part is that I'm seeing it fail in builds and then succeed with a build that is retried. In spite of the documentation (and that providing either an |
@luca-moveshelf yeah, I removed the lock-file and node modules and then did an npm install using npm 8.5, swapped to 8.11 and did an npm ci and got the error. If I do a npm install on only 8.11 or just regenerate the package-lock on 8.11 everything works fine without any special flags. |
If you need force or legacy peer deps, it’s because your dep graph is invalid - nothing should ever have worked, and it’s critically important to break things so you’re notified that your graph is invalid. Your top priority should be fixing your dep graph so that npm install works without any flags. |
@funnylookinhat I also was puzzled by the intermittency of the issue, but I've just realized that Github Actions's Setup Node action logs the cached version of node that it uses: and I've been getting different values for failing and succeeding runs: So that may be something to consider if you are using GH Actions. |
Similar issue between v8.3.1 and v8.3.2 - a package-lock.json that was created with Issue here is that in
@ljharb This may be the case - but the previous package-lock was generated from |
@mofojed the major version change was done in v7, where npm fails to install if your graph is unresolvable. If it's failing now, I'd consider it a bug that it worked before, and that bug has been fixed. |
@ljharb I've created an example project demonstrating the issue: https://github.com/mofojed/npm-scratch I agree there probably was an issue with previous versions of npm, and perhaps even how the package-lock.json was being generated. But shouldn't we deprecate those versions of npm in the registry then? As it is right now, there's definitely a change in behaviour. Even if this is a fix for a bug, I would expect either the previous buggy version to be deprecated, or the new version to be a major version bump. As it is right now, these two versions are not compatible which can cause problems for developers and CI (developer could still be using v8.5.5, CI using v8.x and installs the latest v8.11, and then things break). |
Deprecation isn’t typically used merely for buggy versions; it’s rarely used at all. |
I always considered this to be a feature of npm. Decide once that you want to force whatever npm complains about; npm acknowledges that and stores the forced / desired state in the lock file. From then on, it just takes what's there. It sounds very strange to me that this is a "bug", and it's very bad that this was basically silently introduced to a lot of CI pipelines that stopped to work because they were bumped from Node.js 16.15.0 to 16.15.1 which is a minor patch for which no-one expected any breaking changes |
Right - I'm not implying it be used merely for a buggy version. The problem is usage of these versions is incompatible. A package-lock.json file that works/was created in an older version of 8.x does not work when using a newer version of 8.x. Any CI system specifying just v8.x (or Node 16.x, as v16.15.1 updated npm from 8.5.5 to 8.11.0) is at risk of breaking because of this incompatibility (even if that is a fix from a bug). To avoid this CI must pin a specific version, but then they're at risk for not having the latest security updates. Minor version bumps should not break compatibility, even if it's fixing a previous bug. |
Every single bugfix risks breaking someone relying on the buggy behavior - treating every bug fix as breaking is untenable. |
I consider that an overstatement. My app relies on several packages that are just overly strict when stating their (peer) dependencies - specifically Angular version. They work perfectly fine with newer versions of Angular. I don't have the time to fiddle with all new breaking changes in versions that on paper support newer Angular version (if these versions exists.) I'm fine with adding a permanent I understand treating a bugfix as breaking is untenable, so maybe we can close this linking to the docs and the actual bugfix PR? |
For reference, here was the fix that identified invalid nodes: bd96ae407 #4599 fix(arborist): identify and repair invalid nodes in the virtual tree What was previously "working" with In terms of semantic versioning, on the consumer side, it would have been smoother if I assume people are only hitting this now even though it's been in npm since v8.6.0 because they just update with Node or using nvm, and Node just last week updated to v16.15.1, which updated from v8.5.5 to v8.11.0. In any case, I don't think much can be done about it now. Whoever hits this in their build ci just needs to update their package-lock.json (run |
@kvetis only the package author is the arbiter of "overly strict" - if the package declares a peer dep, then it is not compatible with anything outside of that range, even if it happens to work. |
this would be true if npm resolved semver numbers correctly. But for some reason it thinks |
That is correct; ranges aren’t in the semver spec (yet) so there’s no contradiction. Ranges on a non-prerelease don’t include prereleases, never have, and never will. |
In order to freeze version. To prevent this problem: npm/cli#4998 Also bump up setup-node to version 3 while we're at it.
In order to freeze version. To prevent this problem: npm/cli#4998 Also bump up setup-node to version 3 while we're at it.
I am just coming back to only way to fix it was to run |
Isn't like the entire point of |
Completely, 100% agree! |
For anyone stumbling into this thread looking for clear instructions for a work-around to repair your failed Github Actions build for an Angular project ASAP, this worked for me:
|
Rebuilding the package-lock using the updated versions of node and npm resolved the issue (for us). |
What is the point of using the It used to be a decision made when installing/updating a peer dependency. Once a person had installed a package using That made sense to me. It was nice to get an error. It was nice to tell NPM "hey I checked it works and it's fine". Can this please be reverted? It was working before. |
Same here, suddenly all the pipelines with Node 16 in it started to throw errors. If we are forced to put the My vote is to revert this change as it ruins peoples' time with no reason. |
Did you update your versions locally and rebuild your package-lock file? |
This is exactly what people should not have to do. Their existing package-lock.json file should continue to work. Any requirement otherwise is a breaking change to |
To avoid this kind of issue in the future, I'll pin CI and dev to a specific version of node/npm (using |
No I did not. I have like 100+ dependencies broken, do you want my team to waste a month of work rebuilding the codebase over few hundred repositories? Are you joking? We rolled back to Node v16.15.0, which has a working version of npm 8.5.5.
|
Are there any plans to deprecate / remove support for --legacy-peer-deps in the near future (0-2 years)? |
All you have to do is install node.js 16.15.1 locally and run |
That's what I was saying but apparently that's not ok. It fixed all of our pipelines though. |
The consistency between your It's unfortunate that this fix has caused so many Again, this particular report has to do with using a consistent configuration between the command that generates the lock and the command the uses the lock. As such, I'm going to close this issue. If you'd like to start a discussion around storing the configuration in the lockfile, or other possible behavior changes, please create an RRFC or start a discussion in the repo. That's not to say that there couldn't be bugs that need to be addressed related to lockfile consistency. If you come across one, please submit a bug report. |
it doesn't matter if you think the configurations people used were "correct" or not, as you can see a significant number of people used it this way and it worked before. Now it stopped working, which is a breaking change by definition. The correct way to fix this bug would have been either:
What you just did is incompatible with semver because it breaks people's workflows without declaring a major version bump. What's even worse is that it's not even a minor bump, just a patch. |
It's FTFY. This broke my workplace and many other's CI pipelines, in a patch version no less, and you expect the community to be fine with an "oh well, we'll do better next time" response. Unacceptable. Go back and fix it in a backwards compatible way. My workplace has never used any special flags when running If NPM would've came out and said, "Oops, that was an unexpected consequence of this bugfix - we'll fix it up in the next patch version" I would be completely satisfied. Instead, this issue and its response has caused me to lose all confidence in NPM CLI updates. Guess we'll be pinning an exact version of Node/NPM in our CI pipeline from here on out, or moving to Yarn. |
I have created a pinned issue summarizing this discussion as well as #4664. |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
I've updated to latest node version which use npm 8.11.0, but the problem exist with versions >= 8.6.0 up to 8.12.1
when I do an
npm install --legacy-peer-deps
, all dependencies are correctly installed and I can start my app.but when my CI try do make an
npm ci
, I have conflit errorsExpected Behavior
I should not have any errors when I do
npm ci
since it should use package-lock wich contains all conflict resolutions.If I revert to npm@8.5.5, it works correctly without having to do a new
npm install
Steps To Reproduce
you can also try without --package-lock-only but by removing
node_modules
folderEnvironment
The text was updated successfully, but these errors were encountered: