Skip to content

K4Lok/clearnpmod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧹 clearnpmod

npm version License: MIT Node.js Version

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.

✨ Features

  • 🔍 Recursive scanning - Finds all node_modules folders 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

📦 Installation

Global Installation (Recommended)

npm install -g clearnpmod

Or with pnpm:

pnpm add -g clearnpmod

One-time Usage (npx)

npx clearnpmod <path>

🚀 Usage

Basic Usage

clearnpmod /path/to/your/projects

Examples

# Clean current directory
clearnpmod .

# Clean your entire projects folder
clearnpmod ~/Development

# Clean a specific project
clearnpmod /Users/username/my-project

Interactive Demo

$ 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.

🎯 Use Cases

  • Free up disk space - node_modules can 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

⚠️ Important Notes

  • Backup important projects - Make sure you can reinstall dependencies with npm install or pnpm install
  • Git repositories - Your source code is safe; only node_modules folders are affected
  • Active projects - Avoid deleting node_modules from projects you're currently working on

🛠️ Requirements

  • Node.js >= 14.0.0
  • Works on macOS, Linux, and Windows

🤝 Contributing

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.

Development Setup

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Test locally: node clearnpmod.js <test-path>

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🐛 Issues

If you encounter any problems or have suggestions, please open an issue.

📚 Related Tools

  • npkill - Alternative with a different interface
  • rimraf - For programmatic deletion
  • du - Unix command to check disk usage

Made with ❤️ for the JavaScript community

About

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.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors