简体中文 | English
Blazingly fast scanner to find and clean node_modules across your disks.
--path or input in the interactive menu).--dry-run preview to avoid accidental deletioncd /path/to/clean-node-modules
pnpm add -D pkg
pnpm run build
# Outputs dist/{clean-node-modules-*} binaries for each platform
# No arguments: open the interactive menu (1=dir, 2=all)
node bin/clean-node-modules.js
Interactive menu example:
Please choose: 1) Scan a specific directory 2) Scan the entire machine
# Mode 1: specific directory, delete without prompting
node bin/clean-node-modules.js --mode dir --path /path/to/projects --yes
# Mode 1: preview only (no deletion)
node bin/clean-node-modules.js --mode dir --path /path/to/projects --dry-run
# Mode 2: full disk scan (may be slow)
node bin/clean-node-modules.js --mode all
# Mode 2: scan user home only
node bin/clean-node-modules.js --mode all --path "$HOME"
# Mode 2: full disk scan and delete (dangerous)
node bin/clean-node-modules.js -m all -y
# Or explicitly set root path
node bin/clean-node-modules.js -m all -p / -y
| Option | Description |
|---|---|
| `-m, --mode <dir | all>` |
-p, --path <path> | Start path for dir mode; override start for all mode |
-y, --yes | Delete without confirmation |
-n, --dry-run | Preview node_modules to be deleted without deleting |
-c, --concurrency <num> | Number of concurrent directory reads, default 64 |
-d, --max-depth <num> | Max recursion depth (0=top-level only), default Infinity |
--include-dot | Include hidden directories (starting with .) |
--exclude <a,b,c> | Comma-separated directory names to skip |
-h, --help | Show help |
.git, .hg, .svn, .cache, .idea, .DS_Store, dist, build, out, coverage, .pnpm-store, .npm, .yarn, .nvm, .cargo, .vscode, Pods, DerivedData, android, iosmode=all (macOS typical): Library, Applications, Movies, Music, Pictures, Public, Downloads, DesktopYou can add more via --exclude. Use --include-dot to include hidden directories.
--path "$HOME" or a specific starting path when speed matters.--max-depth to limit traversal (e.g., --max-depth 2).mode=all defaults to root /.mode=all enumerates available drive letters (e.g., C:\\, D:\\).# macOS Apple Silicon
./dist/clean-node-modules-macos-arm64
# macOS Intel
./dist/clean-node-modules-macos-x64
--path "$HOME" or a narrower start path, or lower --max-depth.--yes is provided. Prefer a --dry-run first.--dry-run.PRs are welcome!
git clone https://github.com/wangmiaozero/clean-node-modules.git
cd clean-node-modules
pnpm i
pnpm run build
Before submitting, please ensure:
MIT © 2025 wangmiaozero
See LICENSE