[BUG] Inconsistent `npm install` with workspaces
Open
Nobody has claimed this yet.
Bug
Priority 2
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
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
I need to do npm install twice to have the correct package-lock.json
Expected Behavior
package-lock.json is good on first npm install
Steps To Reproduce
- Download repro repo: https://github.com/Saibamen/npm-bug-repro-workspaces
npm run clean:all(delete allnode_modulesfolders + lock files)npm installnpm audit --omit=dev- ❌ See vulnerabilities from lodash package
npm run clean(deletenode_modulesand lock file, but only in root folder)npm installnpm audit --omit=dev- ❎ No vulnerabilities and changed lock file
Environment
- OS: Windows 11
; node bin location = C:\nvm4w\nodejs\node.exe
; node version = v24.14.0
; npm local prefix = C:\DEV\test_npm
; npm version = 11.12.0
; cwd = C:\DEV\test_npm
; HOME = C:\Users\AdamStachowicz
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked repro repository and start by running the listed clean, install, and npm audit --omit=dev commands on the reported npm and Node versions. Compare the package-lock.json produced after the first and second installs, and use the workspace setup and lockfile changes to define the expected behavior: one npm install should produce the correct lockfile without the reported lodash vulnerability.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100