UNPKG

clearnpmod

Version:

A CLI tool to find and clean up node_modules directories recursively

125 lines (83 loc) โ€ข 3.83 kB
# ๐Ÿงน clearnpmod [![npm version](https://badge.fury.io/js/clearnpmod.svg)](https://badge.fury.io/js/clearnpmod) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](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