1 ---
2 title: npm-dedupe
3 section: 1
4 description: Reduce duplication
5 github_repo: npm/cli
6 github_branch: release/v6
7 github_path: docs/content/commands/npm-dedupe.md
8 redirect_from:
9 - /cli-documentation/v6/cli-commands/dedupe
10 - /cli-documentation/v6/cli-commands/npm-dedupe
11 - /cli-documentation/v6/commands/dedupe
12 - /cli-documentation/v6/commands/npm-dedupe
13 - /cli-documentation/v6/dedupe
14 - /cli-documentation/v6/npm-dedupe
15 - /cli/v6/cli-commands/dedupe
16 - /cli/v6/cli-commands/npm-dedupe
17 - /cli/v6/commands/dedupe
18 - /cli/v6/dedupe
19 - /cli/v6/npm-dedupe
20 ---
21
22 ### Synopsis
23
24 ```bash
25 npm dedupe
26 npm ddp
27
28 aliases: find-dupes, ddp
29 ```
30
31 ### Description
32
33 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.
34
35 For example, consider this dependency graph:
36
37 ```bash
38 a
39 +-- b <-- depends on c@1.0.x
40 | `-- c@1.0.3
41 `-- d <-- depends on c@~1.0.9
42 `-- c@1.0.10
43 ```
44
45 In this case, `npm dedupe` will transform the tree to:
46
47 ```bash
48 a
49 +-- b
50 +-- d
51 `-- c@1.0.10
52 ```
53
54 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.
55
56 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.
57
58 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.
59
60 Arguments are ignored. Dedupe always acts on the entire tree.
61
62 Modules
63
64 Note that this operation transforms the dependency tree, but will never result in new modules being installed.
65
66 ### See Also
67
68 - [npm ls](/cli/v6/commands/npm-ls)
69 - [npm update](/cli/v6/commands/npm-update)
70 - [npm install](/cli/v6/commands/npm-install)