npm / npm/documentation

Warn library authors about caveats of committing package-lock in the source code version control

Open
#810 14 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

content
Dominant language
MDX
Stars
711
Forks
4.2k
Avg merge
4d 16h
Merged PRs (30d)
3

Description

Opening this here again as the repository of the earlier reported issue got archived.
https://github.com/npm/npm/issues/20603

The npm documentation mentions it clearly that package-lock is always meant to be committed, leaving library authors unaware of the risk that their consumers might install different dependency versions than what they're using.

The documentation should be changed to mention that since package-lock files are ignored in published npm packages, library authors should exercise caution when choosing to commit them to source code.

Examples:

  1. https://docs.npmjs.com/cli/v6/configuring-npm/package-locks#using-locked-packages
It is highly recommended you commit the generated package lock to source control
  1. https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#description
This file is intended to be committed into source repositories

Article with reasoning:
https://gajus.medium.com/stop-using-package-lock-json-or-yarn-lock-909035e94328

cc: @gajus

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 reading the package-lock documentation pages linked in the issue, especially the v6 “Using locked packages” and v10 “Description” sections. Update the guidance to explain the caveat for library authors and verify that the wording consistently distinguishes source repositories from published packages.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.