clearnpmod
Version:
A CLI tool to find and clean up node_modules directories recursively
125 lines (83 loc) โข 3.83 kB
Markdown
# ๐งน clearnpmod
[](https://badge.fury.io/js/clearnpmod)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
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)
```bash
npm install -g clearnpmod
```
Or with pnpm:
```bash
pnpm add -g clearnpmod
```
### One-time Usage (npx)
```bash
npx clearnpmod <path>
```
## ๐ Usage
### Basic Usage
```bash
clearnpmod /path/to/your/projects
```
### Examples
```bash
# 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](LICENSE) file for details.
## ๐ Issues
If you encounter any problems or have suggestions, please [open an issue](https://github.com/K4Lok/clearnpmod/issues).
## ๐ Related Tools
- [npkill](https://www.npmjs.com/package/npkill) - Alternative with a different interface
- [rimraf](https://www.npmjs.com/package/rimraf) - For programmatic deletion
- [du](https://linux.die.net/man/1/du) - Unix command to check disk usage
---
Made with โค๏ธ for the JavaScript community