npm / npm/cli

[BUG] package-lock.json contains too many details about the current package.

Open
#4,914 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage 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

The package-lock.json file includes the current package name ($.name), version ($.version), the a current package entry ($.packages[""]).

This has the following negative side effects:

  • It seems less than portable, if for instance I wanted to start another project out with the same set of locked versions by copying the lock file.
  • The lock file can become out of sync with package.json if non-dependency change are made to the package and npm i is not run. Running npm i updates the current package related values in the lock file.

I don't see why the lock file would need these details. It's not necessary to "lock" them. They are available in package.json already, and the lock file is tightly associated with the package file by being adjacent.

Expected Behavior

The current package specific details should be omitted from the package-lock.json so that running npm i after changing the package.json name or version, does not update the lock file.

Steps To Reproduce

Run npm i
Commit the package-lock.json file.
Update package.json version.
Run npm i again
Note the lock file has changes.

Environment
  • npm: 8.5.5
  • Node.js: 16.13.2
  • OS Name: macOS 12.4
  • System Model Name: Macbook Pro M1
  • npm config:
; No, and asking people to post system specific details in a public forum, is shady.

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

The issue names package.json and package-lock.json; start by reproducing the reported npm i sequence and comparing the lock file before and after changing the package version. Done means npm no longer rewrites current-package details in package-lock.json for those changes, while dependency locking remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.