npm / npm/cli

package-lock.json (missing resolved/integrity) not noticed and not repaired automatically by npm

Open
#4,460 23 comments 37 reactions 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

In order to assure reproducible installations, every package listed in a package-lock.json which is fetched from a registry should contain a resolved and integrity field.

This doesn't seem to be the case looking at some existing lockfileVersion = 2 based file.
See for example: https://raw.githubusercontent.com/directus/directus/2938821be05eaf195872c34eed709ac9b4a430b4/package-lock.json

Inspecting the entries for camelcase@6.2.0 (and many others), neither resolved nor integrity exist.

Checking out the repository and executing npm install happily installs camelcase@6.2.0 while:

  • not complaining about the missing integrity
  • not adding the missing information to the package-lock.json file

To fix the lock file, one currently has to:

  • delete all node_modules directories
  • delete the package-lock.json file
  • execute npm install
Expected Behavior
  • When the integrity field is missing for a package, a warning/error should be shown to the user
    (the problem should be of equivalent importance than a mismatching integrity)
  • The broken package-lock.json file should be repaired somehow
    (not necessarily automatically, but the user should be informed about the problem and instructed on how to fix it)
Steps To Reproduce
> git clone https://github.com/directus/directus
> cd directus
> git checkout 2938821be05eaf195872c34eed709ac9b4a430b4
> npm install

lock file is still broken (check entry camelcase@6.2.0)

Environment
  • npm: 8.5.1
  • Node.js: v16.14.0
  • OS Name: docker node:16
  • npm config:
; node bin location = /usr/local/bin/node
; cwd = /
; HOME = /root
; Run `npm config ls -l` to show all defaults.

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

Reproduce the issue by checking out the listed Directus commit and running npm install, then inspect the camelcase@6.2.0 entry in package-lock.json. Determine how npm handles missing resolved and integrity fields, and verify that the completed behavior warns about the broken lockfile and provides repair guidance or repairs it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.