A powerful and interactive CLI tool to find and clean up node_modules directories recursively. Perfect for freeing up disk space by removing unused dependencies across multiple projects.
- 🔍 Recursive scanning - Finds all
node_modulesfolders in a directory tree - ✅ Interactive selection - Checkbox interface to choose which folders to delete
- 🛡️ Safe by default - All folders are pre-selected, but you confirm before deletion
- ⚡ Fast scanning - Efficiently traverses directory structures
- 📊 Clear feedback - Shows progress and results with emojis
- 🚫 Permission handling - Gracefully skips inaccessible directories
npm install -g clearnpmodOr with pnpm:
pnpm add -g clearnpmodnpx clearnpmod <path>clearnpmod /path/to/your/projects# Clean current directory
clearnpmod .
# Clean your entire projects folder
clearnpmod ~/Development
# Clean a specific project
clearnpmod /Users/username/my-project$ clearnpmod ~/Development
Scanning for node_modules folders under:
/Users/username/Development
(This may take a moment...)
? Select which node_modules directories you want to delete: (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
❯◉ /Users/username/Development/project1/node_modules
◉ /Users/username/Development/project2/node_modules
◉ /Users/username/Development/old-project/node_modules
Deleting 3 folder(s)...
✅ Deleted: /Users/username/Development/project1/node_modules
✅ Deleted: /Users/username/Development/project2/node_modules
✅ Deleted: /Users/username/Development/old-project/node_modules
Done.
- Free up disk space -
node_modulescan take up gigabytes of space - Clean old projects - Remove dependencies from projects you're no longer working on
- Prepare for backup - Clean up before backing up your development folder
- System maintenance - Regular cleanup of your development environment
- Backup important projects - Make sure you can reinstall dependencies with
npm installorpnpm install - Git repositories - Your source code is safe; only
node_modulesfolders are affected - Active projects - Avoid deleting
node_modulesfrom projects you're currently working on
- Node.js >= 14.0.0
- Works on macOS, Linux, and Windows
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Clone the repository
- Install dependencies:
pnpm install - Test locally:
node clearnpmod.js <test-path>
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any problems or have suggestions, please open an issue.
- npkill - Alternative with a different interface
- rimraf - For programmatic deletion
- du - Unix command to check disk usage
Made with ❤️ for the JavaScript community