1--- 2section: cli-commands 3title: npm-dedupe 4description: Reduce duplication 5--- 6 7# npm-dedupe(1) 8 9## Reduce duplication 10 11### Synopsis 12```bash 13npm dedupe 14npm ddp 15 16aliases: find-dupes, ddp 17``` 18 19### Description 20 21Searches the local package tree and attempts to simplify the overall 22structure by moving dependencies further up the tree, where they can 23be more effectively shared by multiple dependent packages. 24 25For example, consider this dependency graph: 26 27```bash 28a 29+-- b <-- depends on c@1.0.x 30| `-- c@1.0.3 31`-- d <-- depends on c@~1.0.9 32 `-- c@1.0.10 33``` 34 35In this case, `npm dedupe` will transform the tree to: 36 37```bash 38a 39+-- b 40+-- d 41`-- c@1.0.10 42``` 43 44Because of the hierarchical nature of node's module lookup, b and d 45will both get their dependency met by the single c package at the root 46level of the tree. 47 48The deduplication algorithm walks the tree, moving each dependency as far 49up in the tree as possible, even if duplicates are not found. This will 50result in both a flat and deduplicated tree. 51 52If a suitable version exists at the target location in the tree 53already, then it will be left untouched, but the other duplicates will 54be deleted. 55 56Arguments are ignored. Dedupe always acts on the entire tree. 57 58Modules 59 60Note that this operation transforms the dependency tree, but will never 61result in new modules being installed. 62 63### See Also 64 65* [npm ls](/cli-commands/npm-ls) 66* [npm update](/cli-commands/npm-update) 67* [npm install](/cli-commands/npm-install) 68