-
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 install
removes resolved and integrity fields
#6301
Comments
npm install
removes resolved and integrity fields
We've seen this before but never had a reproduction case for it. That would go a long way to fixing this. |
I can't git this to repro in a ...
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://artifactory.corp.tanium.com/api/npm/tanium-npm/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", <=== inappropriate comma
},
... will reliably induce this in a large Given the invalid-JSON npm ERR! code EUSAGE
npm ERR!
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again. |
I finally found a very simple way to reproduce (npm 9.6.7).
After
After the last command, it contains:
|
Ran into this issue when I deleted Deleting |
Yes the root cause here is if there is a valid tree but NO package-lock, there is no integrity for npm to pull from because that is not something that is in the node_modules folder. Integrity is something that is attached to the .tgz file that is unpacked to GET node_modules. We're still determining if this is a bug. If you didn't get the content from a registry there will be no integrity. |
Fixes #526. This follows the advice specified in npm/cli#6301 for regenerating a package-lock.json file by removing node_modules and package-lock.json. It appears there is an open issue where resolved and integrity fields are removed at times when the above steps are not followed. This also pins `@types/node` to all patch versions as upgrading the major/minor version causes issues in our TypeScript compatibility test since `@types/node` dropped support for v4.1 and Protobuf-ES still supports it. Note that while this fixes the file with this PR, we cannot guarantee that this won't occur again due to the open issue with npm.
The steps I gave in #6301 (comment) are the best I could find to reliably reproduce the problem, however we got it multiple times in cases where a package-lock is actually present. I think it happens when someone from the team pulls commits from GitHub, has an outdated node_modules tree (because dependencies were updated by someone else), and manually changes a dependency version in the package.json (to update it) before running |
Has npm decided if this is a bug, yet?
|
@boneskull can you reliably reproduce this in an isolated case? We're still fuzzy on what the root cause is here. |
As shown in the example repo and from my experience, it only seems to affect dev deps unless someone has a counterexample. I don't know if automated conflict resolution causes it or if workspaces are necessary. |
What exactly is being ran here? |
To cause the conflict? Switch to the |
No, to resolve the conflict. |
|
@wraithgar Can you reproduce? |
Originally these fields were missing due to outstanding issue with npm: - npm/cli#4460 - npm/cli#6301
Originally these fields were missing due to outstanding issue with npm: - npm/cli#4460 - npm/cli#6301
Originally these fields were missing due to outstanding issue with npm: - npm/cli#4460 - npm/cli#6301
This also happens w/ Same root cause: when npm reads from node_modules only to populate lockfile info. |
Workaround
To prevent this from happening repeatedly, I've adopted the following strategy for resolving rm -rf node_modules packages/*/node_modules
npm install
git add -A package-lock.json
Since trash node_modules packages/*/node_modules
npm install
git add -A package-lock.json If you'd prefer something native:
|
When building Packit with Nix (and other sandboxed build systems), these fields are used to prefetch the dependencies. For some reason they are missing from our file for all but one dependency. There seems to be some npm bug that causes these fields to be removed under certain conditions (npm/cli#4263, npm/cli#6301). Deleting the lockfile and running `npm install` again produces a new file that has the missing fields. However in doing so all the dependencies are updated, which I'd rather not right now. Instead I used the script at https://github.com/jeslie0/npm-lockfile to add the fields without changing the version numbers.
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Sometimes, when npm updates the package-lock.json after a
npm install
, it replaces some of the "resolved" and "integrity" fields with "license".Example:

Expected Behavior
npm install
should not randomly change the schema of the lockfile.Steps To Reproduce
I'm still trying to figure out reproduction steps. I think the bug is related to the state of
node_modules
whennpm install
is executed.Environment
The text was updated successfully, but these errors were encountered: