Skip to main content

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

rev-dep node-modules installed-duplicates [flags]

Examples

# Find duplicate packages
rev-dep node-modules installed-duplicates

# Automatically optimize duplicates with size statistics
rev-dep node-modules installed-duplicates --optimize --size-stats

# Optimize with verbose output
rev-dep node-modules installed-duplicates --optimize --verbose

# Isolate symlinks within top-level directories
rev-dep node-modules installed-duplicates --optimize --isolate

Flags

-c, --cwd
string
default:"$PWD"
Working directory for the command
-h, --help
boolean
Help for installed-duplicates
--isolate
boolean
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 effect
--optimize
boolean
Automatically create symlinks to deduplicate packages
--size-stats
boolean
Print node modules dirs size before and after optimization. Might take longer than optimization itself
--verbose
boolean
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.
Always test your application after optimization. While symlinks are generally safe, some tools may not handle them correctly.
Use --size-stats to see exactly how much disk space you’re saving. This can help justify the optimization step.

How It Works

The command identifies packages with identical content (same name and version) installed in multiple locations. When --optimize is used, it:
  1. Finds all duplicate package installations
  2. Keeps one copy of each duplicate
  3. Replaces other copies with symlinks to the kept copy
  4. Optionally displays size savings with --size-stats

Isolation Modes

Creates symlinks between top-level node_modules directories. Maximizes disk space savings in monorepos with workspaces.
rev-dep node-modules installed-duplicates --optimize

Build docs developers (and LLMs) love