Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/lib/content/commands/npm-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ See [package-lock.json](/configuring-npm/package-lock-json).

When you run `npm install` without arguments, npm compares `package.json` and `package-lock.json`:

This behavior applies to npm v7 and later. The lockfile format that npm writes may differ by major version; see [package-lock.json](/configuring-npm/package-lock-json#lockfileversion) for those version-specific details.

* **If the lockfile's resolved versions satisfy the `package.json` ranges:** npm uses the exact versions from `package-lock.json` to ensure reproducible builds across environments.

* **If the ranges don't match:** npm resolves new versions that satisfy the `package.json` ranges and updates `package-lock.json` accordingly. This happens when you modify version ranges in `package.json` (e.g., changing `^7.0.0` to `^8.0.0`). Note that changing a range within the same major version (e.g., `^7.0.0` to `^7.1.0`) will only update the metadata in the lockfile if the currently installed version still satisfies the new range.
Expand Down