-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: npm-dedupe through npm-install
- Loading branch information
Showing
18 changed files
with
428 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
section: cli-commands | ||
section: cli-commands | ||
title: npm-dedupe | ||
description: Reduce duplication | ||
--- | ||
|
@@ -25,7 +25,7 @@ be more effectively shared by multiple dependent packages. | |
|
||
For example, consider this dependency graph: | ||
|
||
```bash | ||
``` | ||
a | ||
+-- b <-- depends on [email protected] | ||
| `-- [email protected] | ||
|
@@ -46,20 +46,35 @@ Because of the hierarchical nature of node's module lookup, b and d | |
will both get their dependency met by the single c package at the root | ||
level of the tree. | ||
The deduplication algorithm walks the tree, moving each dependency as far | ||
up in the tree as possible, even if duplicates are not found. This will | ||
result in both a flat and deduplicated tree. | ||
In some cases, you may have a dependency graph like this: | ||
``` | ||
a | ||
+-- b <-- depends on [email protected] | ||
+-- [email protected] | ||
`-- d <-- depends on [email protected] | ||
`-- [email protected] | ||
``` | ||
During the installation process, the `[email protected]` dependency for `b` was | ||
placed in the root of the tree. Though `d`'s dependency on `[email protected]` could | ||
have been satisfied by `[email protected]`, the newer `[email protected]` dependency was used, | ||
because npm favors updates by default, even when doing so causes | ||
duplication. | ||
|
||
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. | ||
|
||
If a suitable version exists at the target location in the tree | ||
already, then it will be left untouched, but the other duplicates will | ||
be deleted. | ||
To prefer deduplication over novelty during the installation process, run | ||
`npm install --prefer-dedupe` or `npm config set prefer-dedupe true`. | ||
|
||
Arguments are ignored. Dedupe always acts on the entire tree. | ||
|
||
Note that this operation transforms the dependency tree, but will never | ||
result in new modules being installed. | ||
|
||
Using `npm find-dupes` will run the command in dryRun mode. | ||
Using `npm find-dupes` will run the command in `--dry-run` mode. | ||
|
||
### See Also | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.