You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting from npm v10.3.0, optional dependencies for OS and CPU package variants are being pruned from package-lock.json when running npm install and a node_modules folder is present. This breaks npm installs when the resulting lockfile is pulled onto other platforms - such as devs working on their Macs (darwin/arm64) who are pushing their code to CI (linux/x64). This change in behaviour does not appear to be intentional as it is not documented or referenced anywhere. Possibly related to #7543. Possibly a dupe of #4828 and #7750.
The issue may be mitigated by deleting node_modules/ before running the install command.
Expected Behavior
Optional OS and CPU package variants should not be pruned from package-lock.json as was the behaviour prior to npm v10.3.0 to allow the lockfile to be used for cross-platform installs.
Read package-lock.json - observe 18 OS/CPU@rollup/* package variants are listed
rm package-lock.json
npm i
Read package-lock.json - observe only 1 OS/CPU @rollup/* package variant is now listed for the current platform
Expected behaviour test 1 ✅:
mkdir test && cd test
npm init -y
npm i -D rollup
Read package-lock.json - observe 18 OS/CPU@rollup/* package variants are listed
rm -rf node_modules
npm i
Read package-lock.json - observe 18 OS/CPU@rollup/* package variants are listed
Expected behaviour test 2 ✅:
mkdir test && cd test
npm init -y
npm i -D rollup
Read package-lock.json - observe 18 OS/CPU@rollup/* package variants are listed
npm i -D esbuild
Read package-lock.json - observe 18 OS/CPU@rollup/* package variants are listed
Environment
npm: 10.9.2
Node.js: 22.17
OS Name: macOS 14.5
System Model Name: M1 Macbook Pro
npm config:
; node bin location = /Users/xxx/.nvm/versions/node/v20.17.0/bin/node; node version = v20.17.0; npm local prefix = /Users/xxx/Projects/test; npm version = 10.9.2; cwd = /Users/xxx/Projects/test; HOME = /Users/xxx; Run `npm config ls -l` to show all defaults.
The text was updated successfully, but these errors were encountered:
@i-like-robots by running the above commands u mentioned we are not getting any issue which above mentioned. by running the commands above mentioned by u we get 18 package variants before deleting the package-lock.json and after deleting package-lock.json we get the same 18 package variants.this is not an issue
Thanks for your comment @kchindam-infy, unfortunately we have multiple users affected by this issue and I am able to recreate the issue myself on multiple machines, node and npm versions.
If it helps to diagnose the issue further, I have made a screen recording performing the steps reproducing the unexpected behaviour;
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Starting from npm v10.3.0, optional dependencies for OS and CPU package variants are being pruned from
package-lock.json
when runningnpm install
and anode_modules
folder is present. This breaks npm installs when the resulting lockfile is pulled onto other platforms - such as devs working on their Macs (darwin/arm64) who are pushing their code to CI (linux/x64). This change in behaviour does not appear to be intentional as it is not documented or referenced anywhere. Possibly related to #7543. Possibly a dupe of #4828 and #7750.The issue may be mitigated by deleting
node_modules/
before running the install command.Expected Behavior
Optional OS and CPU package variants should not be pruned from
package-lock.json
as was the behaviour prior to npm v10.3.0 to allow the lockfile to be used for cross-platform installs.Steps To Reproduce
Unexpected behaviour ❌:
mkdir test && cd test
npm init -y
npm i -D rollup
package-lock.json
- observe 18 OS/CPU@rollup/*
package variants are listedrm package-lock.json
npm i
package-lock.json
- observe only 1 OS/CPU@rollup/*
package variant is now listed for the current platformExpected behaviour test 1 ✅:
mkdir test && cd test
npm init -y
npm i -D rollup
package-lock.json
- observe 18 OS/CPU@rollup/*
package variants are listedrm -rf node_modules
npm i
package-lock.json
- observe 18 OS/CPU@rollup/*
package variants are listedExpected behaviour test 2 ✅:
mkdir test && cd test
npm init -y
npm i -D rollup
package-lock.json
- observe 18 OS/CPU@rollup/*
package variants are listednpm i -D esbuild
package-lock.json
- observe 18 OS/CPU@rollup/*
package variants are listedEnvironment
The text was updated successfully, but these errors were encountered: