npm / npm/cli

[BUG] `node_modules/.package-lock.json` contains `lockfileVersion` 2 instead of 3

Open
#3,971 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Documentation 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
Current Behavior

npm install creates node_modules/.package-lock.json with "lockfileVersion": 2,.

Expected Behavior

As per https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json#lockfileversion npm v7 and later should set lockfileVersion of that hidden lockfile to 3.

2: The lockfile version used by npm v7, which is backwards compatible to v1 lockfiles.
3: The lockfile version used by npm v7, without backwards compatibility affordances. This is used for the hidden lockfile at node_modules/.package-lock.json, and will likely be used in a future version of npm, once support for npm v6 is no longer relevant.

Steps To Reproduce
mkdir test
cd test
npm init -y
npm install vue
grep lockfileVersion node_modules/.package-lock.json
Environment
  • OS: not applicable (macOS Bir Sur 11.6, macOS Bir Sur 11.6, Ubuntu Focal, Ubuntu Focal)
  • Node: not applicable (v16.13.0, v15.14.0, v14.17.5, v14.17.5)
  • npm: any after v7? (v8.1.2, v7.24.1, v7.22.0, v7.0.0)

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

Start by reproducing the npm install vue sequence and inspect node_modules/.package-lock.json, the only artifact named in the issue. Trace the npm CLI path that generates this hidden lockfile, then verify that the result uses lockfileVersion 3 and that the relevant tests cover the behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.