node-modules-deleter
v1.0.3
Published
CLI tool to delete node_modules directories
Readme
🧹 Node Module Deleter
A command-line interface (CLI) tool to help you find and delete node_modules directories in your projects, freeing up valuable disk space.
` Node modules can consume a significant amount of disk space, especially if you work with many JavaScript projects. This tool provides an easy way to locate these directories and either delete them all at once or selectively choose which ones to remove.
✨ Features
- Scan for all
node_modulesdirectories: Recursively searches the current directory for allnode_modulesfolders. - List directories with their size and path: Provides details about each found
node_modulesdirectory when using the--listoption. - Interactively select directories to delete: Choose specific
node_modulesfolders to remove from a list. - Bulk deletion: Option to delete all found
node_modulesdirectories in one go. - Calculates freed space: Shows you how much disk space you've reclaimed after deletion.
- Graceful exit: Handles
Ctrl+Cgracefully.
🚀 Installation
You can install this CLI tool using npm:
npm install node-modules-deleterFor global install:
npm install -g node-modules-deleterIf you're running it locally from the source, you can simply execute it using node:
# Navigate to the directory containing the script
node index.js [command] [options]💡 Usage
The primary command is scan, which searches for node_modules directories.
nmd scan [options]Options
-v, --version: Show version number.--list: List all foundnode_modulesdirectories with their size and path, and allow interactive selection for deletion.
Examples
1. Scan and Delete All node_modules
To scan the current directory and be prompted to delete all found node_modules directories:
nmd scanYou will see output similar to this:
Scanning for 'node_modules' directories.
✔ Scanning...
Found 3 'node_modules' directories.
? Do you want to delete all the found node_modules directories? (y/N)If you confirm, all found node_modules folders will be deleted.
2. Scan and Interactively Select node_modules to Delete
To scan and get a list of all node_modules directories, allowing you to pick which ones to delete:
nmd scan --listThis will output a list and prompt you for selection:
Scanning for 'node_modules' directories.
✔ Scanning...
Found 3 'node_modules' directories:
? Select node_modules directories to delete: (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to continue)
◯ /Users/username/projects/project1/node_modules
◯ /Users/username/projects/project2/frontend/node_modules
◯ /Users/username/projects/project3/backend/node_modulesUse the spacebar to select individual directories, or a to toggle all, then press enter to proceed with deletion.
3. Show Version
To check the version of the CLI tool:
nmd -v
# or
nmd --version