.TH "NPM\-DEDUPE" "1" "November 2022" "9.1.1" .SH "NAME" \fBnpm-dedupe\fR .SH Synopsis .SH Description .P Searches the local package tree and attempts to simplify the overall .br structure by moving dependencies further up the tree, where they can .br be more effectively shared by multiple dependent packages\. .P For example, consider this dependency graph: .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: .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 .br will both get their dependency met by the single c package at the root .br level of the tree\. .P In some cases, you may have a dependency graph like this: .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 .br placed in the root of the tree\. Though \fBd\fP\|'s dependency on \fBc@1\.x\fP could .br have been satisfied by \fBc@1\.0\.3\fP, the newer \fBc@1\.9\.0\fP dependency was used, .br because npm favors updates by default, even when doing so causes .br duplication\. .P Running \fBnpm dedupe\fP will cause npm to note the duplication and .br re\-evaluate, deleting the nested \fBc\fP module, because the one in the root is .br sufficient\. .P To prefer deduplication over novelty during the installation process, run .br \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 .br result in new modules being installed\. .P Using \fBnpm find\-dupes\fP will run the command in \fB\-\-dry\-run\fP mode\. .P Note: \fBnpm dedupe\fP will never update the semver values of direct .br dependencies in your project \fBpackage\.json\fP, if you want to update .br values in \fBpackage\.json\fP you can run: \fBnpm update \-\-save\fP instead\. .SH Configuration .SH See Also .RS 1 .IP \(bu 2 npm find\-dupes .IP \(bu 2 npm ls .IP \(bu 2 npm update .IP \(bu 2 npm install .RE