npm / npm/cli

[BUG] Inconsistent `npm install` with workspaces

Open
#9,135 4 comments 0 reactions 0 assignees View on GitHub

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
  1. Download repro repo: https://github.com/Saibamen/npm-bug-repro-workspaces
  2. npm run clean:all (delete all node_modules folders + lock files)
  3. npm install
  4. npm audit --omit=dev
  5. See vulnerabilities from lodash package
  6. npm run clean (delete node_modules and lock file, but only in root folder)
  7. npm install
  8. npm audit --omit=dev
  9. ❎ 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.