npm / npm/cli

[BUG] `npm update` deletes name property of @scoped workspace dependencies from the package-lock

Open
#4,521 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 8.x
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

When using workspaces some of the workspace names may be scoped. When this is the case the package-lock includes the "name" property of the scoped, locally resolved packages. Running npm update removes the name properties, causing resolution issues later during release, after running npm install after an npm version.

Expected Behavior

The command npm update preserves the name property in the package-lock.json when present.

Steps To Reproduce
  1. Using npm@8.5.3 with Node 16
  2. Run:
git clone https://github.com/riovir/npm-update-deleted-name-reprod.git
cd npm-update-deleted-name-reprod
npm ci
npm update
git diff
  1. Notice how the name props are missing.
  2. Note that running npm install puts them back.
Environment
  • npm: 8.5.3
  • Node.js: 16.14.0
  • OS Name: Windows 10 Pro

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 riovir/npm-update-deleted-name-reprod and run the listed npm ci, npm update, and git diff steps to reproduce the package-lock.json change. Trace the npm update handling for scoped workspace dependencies and verify that the name properties remain after updating, while npm install continues to restore them when needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.