1NPM-DEDUPE(1) NPM-DEDUPE(1)
2
3
4
6 npm-dedupe - Reduce duplication in the package tree
7
8 Synopsis
9 npm dedupe
10 npm ddp
11
12 aliases: ddp
13
14 Description
15 Searches the local package tree and attempts to simplify the overall
16 structure by moving dependencies further up the tree, where they can be
17 more effectively shared by multiple dependent packages.
18
19 For example, consider this dependency graph:
20
21 a
22 +-- b <-- depends on c@1.0.x
23 | `-- c@1.0.3
24 `-- d <-- depends on c@~1.0.9
25 `-- c@1.0.10
26
27 In this case, npm dedupe will transform the tree to:
28
29 a
30 +-- b
31 +-- d
32 `-- c@1.0.10
33
34 Because of the hierarchical nature of node's module lookup, b and d
35 will both get their dependency met by the single c package at the root
36 level of the tree.
37
38 In some cases, you may have a dependency graph like this:
39
40 a
41 +-- b <-- depends on c@1.0.x
42 +-- c@1.0.3
43 `-- d <-- depends on c@1.x
44 `-- c@1.9.9
45
46 During the installation process, the c@1.0.3 dependency for b was
47 placed in the root of the tree. Though d's dependency on c@1.x could
48 have been satisfied by c@1.0.3, the newer c@1.9.0 dependency was used,
49 because npm favors updates by default, even when doing so causes dupli‐
50 cation.
51
52 Running npm dedupe will cause npm to note the duplication and re-evalu‐
53 ate, deleting the nested c module, because the one in the root is suf‐
54 ficient.
55
56 To prefer deduplication over novelty during the installation process,
57 run npm install --prefer-dedupe or npm config set prefer-dedupe true.
58
59 Arguments are ignored. Dedupe always acts on the entire tree.
60
61 Note that this operation transforms the dependency tree, but will never
62 result in new modules being installed.
63
64 Using npm find-dupes will run the command in --dry-run mode.
65
66 Configuration
67 <!-- AUTOGENERATED CONFIG DESCRIPTIONS START --> <!-- automatically
68 generated, do not edit manually --> <!-- see lib/utils/config/defini‐
69 tions.js -->
70
71 global-style
72 • Default: false
73
74 • Type: Boolean
75
76
77 Causes npm to install the package into your local node_modules folder
78 with the same layout it uses with the global node_modules folder. Only
79 your direct dependencies will show in node_modules and everything they
80 depend on will be flattened in their node_modules folders. This obvi‐
81 ously will eliminate some deduping. If used with legacy-bundling,
82 legacy-bundling will be preferred. <!-- automatically generated, do
83 not edit manually --> <!-- see lib/utils/config/definitions.js -->
84
85
86 legacy-bundling
87 • Default: false
88
89 • Type: Boolean
90
91
92 Causes npm to install the package such that versions of npm prior to
93 1.4, such as the one included with node 0.8, can install the package.
94 This eliminates all automatic deduping. If used with global-style this
95 option will be preferred. <!-- automatically generated, do not edit
96 manually --> <!-- see lib/utils/config/definitions.js -->
97
98
99 strict-peer-deps
100 • Default: false
101
102 • Type: Boolean
103
104
105 If set to true, and --legacy-peer-deps is not set, then any conflicting
106 peerDependencies will be treated as an install failure, even if npm
107 could reasonably guess the appropriate resolution based on non-peer de‐
108 pendency relationships.
109
110 By default, conflicting peerDependencies deep in the dependency graph
111 will be resolved using the nearest non-peer dependency specification,
112 even if doing so will result in some packages receiving a peer depen‐
113 dency outside the range set in their package's peerDependencies object.
114
115 When such and override is performed, a warning is printed, explaining
116 the conflict and the packages involved. If --strict-peer-deps is set,
117 then this warning is treated as a failure. <!-- automatically gener‐
118 ated, do not edit manually --> <!-- see lib/utils/config/definitions.js
119 -->
120
121
122 package-lock
123 • Default: true
124
125 • Type: Boolean
126
127
128 If set to false, then ignore package-lock.json files when installing.
129 This will also prevent writing package-lock.json if save is true.
130
131 When package package-locks are disabled, automatic pruning of extrane‐
132 ous modules will also be disabled. To remove extraneous modules with
133 package-locks disabled use npm prune. <!-- automatically generated, do
134 not edit manually --> <!-- see lib/utils/config/definitions.js -->
135
136
137 omit
138 • Default: 'dev' if the NODE_ENV environment variable is set to 'pro‐
139 duction', otherwise empty.
140
141 • Type: "dev", "optional", or "peer" (can be set multiple times)
142
143
144 Dependency types to omit from the installation tree on disk.
145
146 Note that these dependencies are still resolved and added to the pack‐
147 age-lock.json or npm-shrinkwrap.json file. They are just not physically
148 installed on disk.
149
150 If a package type appears in both the --include and --omit lists, then
151 it will be included.
152
153 If the resulting omit list includes 'dev', then the NODE_ENV environ‐
154 ment variable will be set to 'production' for all lifecycle scripts.
155 <!-- automatically generated, do not edit manually --> <!-- see
156 lib/utils/config/definitions.js -->
157
158
159 ignore-scripts
160 • Default: false
161
162 • Type: Boolean
163
164
165 If true, npm does not run scripts specified in package.json files.
166
167 Note that commands explicitly intended to run a particular script, such
168 as npm start, npm stop, npm restart, npm test, and npm run-script will
169 still run their intended script if ignore-scripts is set, but they will
170 not run any pre- or post-scripts. <!-- automatically generated, do not
171 edit manually --> <!-- see lib/utils/config/definitions.js -->
172
173
174 audit
175 • Default: true
176
177 • Type: Boolean
178
179
180 When "true" submit audit reports alongside the current npm command to
181 the default registry and all registries configured for scopes. See the
182 documentation for npm help audit for details on what is submitted.
183 <!-- automatically generated, do not edit manually --> <!-- see
184 lib/utils/config/definitions.js -->
185
186
187 bin-links
188 • Default: true
189
190 • Type: Boolean
191
192
193 Tells npm to create symlinks (or .cmd shims on Windows) for package ex‐
194 ecutables.
195
196 Set to false to have it not do this. This can be used to work around
197 the fact that some file systems don't support symlinks, even on osten‐
198 sibly Unix systems. <!-- automatically generated, do not edit manually
199 --> <!-- see lib/utils/config/definitions.js -->
200
201
202 fund
203 • Default: true
204
205 • Type: Boolean
206
207
208 When "true" displays the message at the end of each npm install ac‐
209 knowledging the number of dependencies looking for funding. See npm
210 help npm fund for details. <!-- automatically generated, do not edit
211 manually --> <!-- see lib/utils/config/definitions.js -->
212
213
214 dry-run
215 • Default: false
216
217 • Type: Boolean
218
219
220 Indicates that you don't want npm to make any changes and that it
221 should only report what it would have done. This can be passed into any
222 of the commands that modify your local installation, eg, install, up‐
223 date, dedupe, uninstall, as well as pack and publish.
224
225 Note: This is NOT honored by other network related commands, eg
226 dist-tags, owner, etc. <!-- automatically generated, do not edit manu‐
227 ally --> <!-- see lib/utils/config/definitions.js -->
228
229
230 workspace
231 • Default:
232
233 • Type: String (can be set multiple times)
234
235
236 Enable running a command in the context of the configured workspaces of
237 the current project while filtering by running only the workspaces de‐
238 fined by this configuration option.
239
240 Valid values for the workspace config are either:
241
242 • Workspace names
243
244 • Path to a workspace directory
245
246 • Path to a parent workspace directory (will result to selecting all of
247 the nested workspaces)
248
249
250 When set for the npm init command, this may be set to the folder of a
251 workspace which does not yet exist, to create the folder and set it up
252 as a brand new workspace within the project.
253
254 This value is not exported to the environment for child processes.
255 <!-- automatically generated, do not edit manually --> <!-- see
256 lib/utils/config/definitions.js -->
257
258
259 workspaces
260 • Default: false
261
262 • Type: Boolean
263
264
265 Enable running a command in the context of all the configured
266 workspaces.
267
268 This value is not exported to the environment for child processes.
269 <!-- automatically generated, do not edit manually --> <!-- see
270 lib/utils/config/definitions.js -->
271
272 <!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
273
274
275 See Also
276 • npm help find-dupes
277
278 • npm help ls
279
280 • npm help update
281
282 • npm help install
283
284
285
286
287 October 2021 NPM-DEDUPE(1)