1NPM-DEDUPE(1)                                                    NPM-DEDUPE(1)
2
3
4

NAME

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