Description
Identifies packages that are installed multiple times in node_modules. Can optimize storage by creating symlinks between duplicate packages, reducing disk space usage.Usage
Examples
Flags
Working directory for the command
Help for installed-duplicates
Create symlinks only within the same top-level node_module directories. By default, optimize creates symlinks between top-level node_module directories (e.g. when workspaces are used). Needs
--optimize flag to take effectAutomatically create symlinks to deduplicate packages
Print node modules dirs size before and after optimization. Might take longer than optimization itself
Show detailed information about each optimization
Use Cases
Disk Space Optimization
Reduce disk space usage by deduplicating identical package installations.
Monorepo Optimization
Deduplicate packages across workspace packages by creating symlinks between top-level node_modules directories.
Workspace Isolation
Use
--isolate to keep symlinks within each workspace’s node_modules for stricter isolation.How It Works
The command identifies packages with identical content (same name and version) installed in multiple locations. When--optimize is used, it:
- Finds all duplicate package installations
- Keeps one copy of each duplicate
- Replaces other copies with symlinks to the kept copy
- Optionally displays size savings with
--size-stats
Isolation Modes
- Default (Cross-workspace)
- Isolated (Per-workspace)
Creates symlinks between top-level node_modules directories. Maximizes disk space savings in monorepos with workspaces.
Related Commands
- node-modules dirs-size - Calculate total size of node_modules directories
