LinuxCommandLibrary

npm-dedupe

reduces duplication in the package tree by moving dependencies higher

TLDR

Deduplicate dependencies

$ npm dedupe
copy
Dry run (show what would change)
$ npm dedupe --dry-run
copy
Include dev dependencies
$ npm dedupe --include=dev
copy
Dedupe with legacy bundling
$ npm dedupe --legacy-bundling
copy

SYNOPSIS

npm dedupe [options]

DESCRIPTION

npm dedupe reduces duplication in the package tree by moving dependencies higher in the tree where they can be shared. This can reduce node_modules size significantly.
The command restructures but doesn't change package-lock.json versions.

PARAMETERS

--dry-run

Show changes without applying.
--include type
Include dependency type.
--omit type
Omit dependency type.
--legacy-bundling
Use legacy algorithm.
--strict-peer-deps
Fail on peer dep issues.

EXAMPLE

$ # Before dedupe
node_modules/
├── a/
│   └── node_modules/lodash@4.0.0
└── b/
    └── node_modules/lodash@4.0.0

# After dedupe
node_modules/
├── a/
├── b/
└── lodash@4.0.0
copy

CAVEATS

May not reduce size if version ranges differ. Run after npm install. Restructures tree only.

HISTORY

npm dedupe was introduced to help manage the duplicate dependency problem common in npm's nested node_modules structure.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community