| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 482b256 commit 048f7a5
321 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,7 @@ a | |||
| 48 | 48 | ``` | |
| 49 | 49 | ||
| 50 | 50 | During the installation process, the `c@1.0.3` dependency for `b` was placed in the root of the tree. | |
| 51 | - Though `d`'s dependency on `c@1.x` could have been satisfied by `c@1.0.3`, the newer `c@1.9.0` dependency was used, because npm favors updates by default, even when doing so causes duplication. | ||
| 51 | + Though `d`'s dependency on `c@1.x` could have been satisfied by `c@1.0.3`, the newer `c@1.9.9` dependency was used, because npm favors updates by default, even when doing so causes duplication. | ||
| 52 | 52 | ||
| 53 | 53 | Running `npm dedupe` will cause npm to note the duplication and re-evaluate, deleting the nested `c` module, because the one in the root is sufficient. | |
| 54 | 54 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,18 @@ If the package has a package-lock, or an npm shrinkwrap file, or a yarn lock fil | |||
| 23 | 23 | ||
| 24 | 24 | See [package-lock.json](/configuring-npm/package-lock-json) and [`npm shrinkwrap`](/commands/npm-shrinkwrap). | |
| 25 | 25 | ||
| 26 | + #### How `npm install` uses `package-lock.json` | ||
| 27 | + | ||
| 28 | + When you run `npm install` without arguments, npm compares `package.json` and `package-lock.json`: | ||
| 29 | + | ||
| 30 | + * **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. | ||
| 31 | + | ||
| 32 | + * **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. | ||
| 33 | + | ||
| 34 | + In essence, `package-lock.json` locks your dependencies to specific versions, but `package.json` is the source of truth for acceptable version ranges. When the lockfile's versions satisfy the `package.json` ranges, the lockfile wins. When they conflict, `package.json` wins and the lockfile is updated. | ||
| 35 | + | ||
| 36 | + If you want to install packages while ensuring that `package.json` is not modified and that both files are strictly in sync, use [`npm ci`](/commands/npm-ci) instead. | ||
| 37 | + | ||
| 26 | 38 | A `package` is: | |
| 27 | 39 | ||
| 28 | 40 | * a) a folder containing a program described by a [`package.json`](/configuring-npm/package-json) file | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,7 @@ Note that nested packages will *also* show the paths to the specified packages. | |||
| 23 | 23 | For example, running `npm ls promzard` in npm's source tree will show: | |
| 24 | 24 | ||
| 25 | 25 | ```bash | |
| 26 | - npm@11.7.0 /path/to/npm | ||
| 26 | + npm@11.8.0 /path/to/npm | ||
| 27 | 27 | └─┬ init-package-json@0.0.4 | |
| 28 | 28 | └── promzard@0.1.5 | |
| 29 | 29 | ``` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces. | |||
| 14 | 14 | ||
| 15 | 15 | ### Version | |
| 16 | 16 | ||
| 17 | - 11.7.0 | ||
| 17 | + 11.8.0 | ||
| 18 | 18 | ||
| 19 | 19 | ### Description | |
| 20 | 20 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-access----1170"> | ||
| 144 | + <h1 id="----npm-access----1180"> | ||
| 145 | 145 | <span>npm-access</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Set access level on published packages</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-adduser----1170"> | ||
| 144 | + <h1 id="----npm-adduser----1180"> | ||
| 145 | 145 | <span>npm-adduser</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Add a registry user account</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-audit----1170"> | ||
| 144 | + <h1 id="----npm-audit----1180"> | ||
| 145 | 145 | <span>npm-audit</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Run a security audit</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-bugs----1170"> | ||
| 144 | + <h1 id="----npm-bugs----1180"> | ||
| 145 | 145 | <span>npm-bugs</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Report bugs for a package in a web browser</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-cache----1170"> | ||
| 144 | + <h1 id="----npm-cache----1180"> | ||
| 145 | 145 | <span>npm-cache</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Manipulates packages cache</span> | |
| 149 | 149 | </header> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,9 +141,9 @@ | |||
| 141 | 141 | ||
| 142 | 142 | <section id="content"> | |
| 143 | 143 | <header class="title"> | |
| 144 | - <h1 id="----npm-ci----1170"> | ||
| 144 | + <h1 id="----npm-ci----1180"> | ||
| 145 | 145 | <span>npm-ci</span> | |
| 146 | - <span class="version">@11.7.0</span> | ||
| 146 | + <span class="version">@11.8.0</span> | ||
| 147 | 147 | </h1> | |
| 148 | 148 | <span class="description">Clean install a project</span> | |
| 149 | 149 | </header> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments