@morningljn/clean-node-modules
v1.0.0
Published
Scan and clean node_modules safely on macOS - moves to Trash, never rm
Maintainers
Readme
Features
- Scan — Recursively find all
node_modulesunder your home directory - Interactive — Multi-select with space bar, confirm with enter
- Safe — Moves to macOS Trash (recoverable via Finder), never
rm -rf - Smart — Skips system dirs (
.Trash,Library,.cache, etc.) - Flexible — Custom scan path, global mode, dry-run supported
Install
# Clone and build
git clone https://github.com/ArtLjn/clean-node-modules.git
cd clean-node-modules
npm install && npm run build
# Copy to PATH
cp dist/index.cjs ~/.local/bin/cnm && chmod +x ~/.local/bin/cnmUsage
cnm # Scan home directory, select to clean
cnm --dry-run # Preview only, no changes
cnm -g # Include global node_modules
cnm --path ~/projects # Scan a specific directory
cnm -h # HelpHow It Works
- Recursively walks your directory tree (max depth 20)
- Skips
.Trash,Library,.cache, and other system directories - Calculates each
node_modulessize viadu -sk - Displays sorted list with interactive checkbox selection
- Moves selected directories to
~/.Trash/(with conflict handling) - Falls back to
osascriptFinder move if cross-volume rename fails
Recovery
Cleaned directories go to macOS Trash. A .node_modules-trashed marker file is left in the original project directory with the restore command:
# Example restore
mv ~/.Trash/node_modules "/path/to/project/node_modules"