[BUG] package-lock.json contains too many details about the current package.
Nobody has claimed this yet.
- 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.jsonif non-dependency change are made to the package andnpm iis not run. Runningnpm iupdates 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
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
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