summaryrefslogtreecommitdiff
path: root/deps/npm/man/man1/npm-dedupe.1
blob: 70267ff45ec6c00327f2de13a9255b2b79c25f57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.TH "NPM\-DEDUPE" "1" "March 2021" "" ""
.SH "NAME"
\fBnpm-dedupe\fR \- Reduce duplication
.SS Synopsis
.P
.RS 2
.nf
npm dedupe
npm ddp

aliases: find\-dupes, ddp
.fi
.RE
.SS Description
.P
Searches the local package tree and attempts to simplify the overall
structure by moving dependencies further up the tree, where they can
be more effectively shared by multiple dependent packages\.
.P
For example, consider this dependency graph:
.P
.RS 2
.nf
a
+\-\- b <\-\- depends on c@1\.0\.x
|   `\-\- c@1\.0\.3
`\-\- d <\-\- depends on c@~1\.0\.9
    `\-\- c@1\.0\.10
.fi
.RE
.P
In this case, \fBnpm dedupe\fP will transform the tree to:
.P
.RS 2
.nf
a
+\-\- b
+\-\- d
`\-\- c@1\.0\.10
.fi
.RE
.P
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\.
.P
In some cases, you may have a dependency graph like this:
.P
.RS 2
.nf
a
+\-\- b <\-\- depends on c@1\.0\.x
+\-\- c@1\.0\.3
`\-\- d <\-\- depends on c@1\.x
    `\-\- c@1\.9\.9
.fi
.RE
.P
During the installation process, the \fBc@1\.0\.3\fP dependency for \fBb\fP was
placed in the root of the tree\.  Though \fBd\fP\|'s dependency on \fBc@1\.x\fP could
have been satisfied by \fBc@1\.0\.3\fP, the newer \fBc@1\.9\.0\fP dependency was used,
because npm favors updates by default, even when doing so causes
duplication\.
.P
Running \fBnpm dedupe\fP will cause npm to note the duplication and
re\-evaluate, deleting the nested \fBc\fP module, because the one in the root is
sufficient\.
.P
To prefer deduplication over novelty during the installation process, run
\fBnpm install \-\-prefer\-dedupe\fP or \fBnpm config set prefer\-dedupe true\fP\|\.
.P
Arguments are ignored\. Dedupe always acts on the entire tree\.
.P
Note that this operation transforms the dependency tree, but will never
result in new modules being installed\.
.P
Using \fBnpm find\-dupes\fP will run the command in \fB\-\-dry\-run\fP mode\.
.SS See Also
.RS 0
.IP \(bu 2
npm ls \fI/cli\-commands/ls\fR
.IP \(bu 2
npm update \fI/cli\-commands/update\fR
.IP \(bu 2
npm install \fI/cli\-commands/install\fR

.RE