Skip to content

[BUG] npm install produces different results on first and second run #8535

@liamcmitchell

Description

@liamcmitchell

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Discovered here: electron-userland/electron-builder#9259

A clean npm install produces different results on the first and second run.

Expected Behavior

npm install should produce the same results each time.

Steps To Reproduce

On mac, ignoring scripts just in case:

npm install -g npm@latest
mkdir test && cd test
npm init -y
npm install --ignore-scripts @abandonware/noble
# added 156 packages, and audited 157 packages in 972ms
npm install --ignore-scripts
# changed 12 packages, and audited 157 packages in 542ms

The second install shows "changed 12 packages" which is unexpected. This is also reproducible installing from package/lock files.

rm -rf node_modules
npm install --ignore-scripts
# added 156 packages, and audited 157 packages in 1s
npm install --ignore-scripts
# changed 12 packages, and audited 157 packages in 553ms

The different results are visible in the FS by diffing the output of find node_modules before and after.

Environment

  • npm: 11.5.2
  • Node.js: v22.14.0
  • OS Name: MacOS
  • System Model Name: Macbook Pro M4
  • npm config:
; node bin location = /Users/liam.mitchell/.local/share/fnm/node-versions/v22.14.0/installation/bin/node
; node version = v22.14.0
; npm local prefix = /Users/liam.mitchell/npm-install
; npm version = 11.5.2
; cwd = /Users/liam.mitchell/npm-install
; HOME = /Users/liam.mitchell

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions