@zandd/pnm
v1.0.1
Published
A CLI tool to purge node_modules directories and free up disk space
Maintainers
Readme
PNM - Purge Node Modules 🧹
A powerful CLI tool to find and delete node_modules directories, helping you reclaim valuable disk space.
Features
- 🔍 Recursive Scanning: Finds all top-level
node_modulesdirectories in a given path - 📊 Detailed Analysis: Shows total space to be freed, number of files, and directory count
- ✅ Safe Deletion: Requires confirmation before deleting (unless using
-yflag) - 🎯 Dry Run Mode: Preview what would be deleted without actually deleting
- 🎨 Beautiful CLI: Colorful output with progress indicators
- ⚡ Fast: Efficient scanning and deletion process
Installation
Global Installation (Recommended)
npm install -g @zandd/pnmUse with npx (No Installation Required)
npx @zandd/pnm [path]Usage
Basic Usage
Scan and clean the current directory:
pnmScan and clean a specific directory:
pnm /path/to/your/projectsOptions
pnm [path] [options]Options:
-t, --test- Show directory size and potential cleanup without deleting-d, --delete- Delete node_modules directories-r, --restore- Run npm install to restore packages in all projects (works independently)-y, --yes- Skip confirmation and delete immediately-V, --version- Output the version number-h, --help- Display help information
Examples
Test to see potential space savings (safe):
pnm ~/projects --testDelete node_modules directories:
pnm ~/projects --deleteDelete without confirmation:
pnm ~/projects --delete --yesDelete and restore packages:
pnm ~/projects --delete --restoreJust restore packages (without deleting):
pnm ~/projects --restoreScan current directory:
pnm .Output Example
🔍 PNM - Purge Node Modules
Scanning for node_modules directories in: C:\Users\Dev\Projects
✓ Found 15 node_modules directories
Analyzing directories...
✓ Analysis complete
Summary:
📁 Directories found: 15
📄 Total files: 245,832
💾 Space to be freed: 2.4 GB
Directories to be deleted:
1. C:\Users\Dev\Projects\project1\node_modules
2. C:\Users\Dev\Projects\project2\node_modules
...
? Are you sure you want to delete 15 node_modules directories? (y/N)
✓ Deleted 15 directories
✓ Successfully deleted all node_modules directories!
💾 Space freed: 2.4 GB
📄 Files removed: 245,832How It Works
- Scanning: Recursively scans the specified directory for
node_modulesfolders - Analysis: Calculates the total size and file count of all found directories
- Summary: Displays a detailed summary of what will be deleted
- Confirmation: Asks for user confirmation (unless
--yesflag is used) - Deletion: Safely removes all
node_modulesdirectories - Report: Shows the final statistics of freed space and removed files
Development
Setup
# Clone the repository
git clone https://github.com/zandd/pnm.git
cd pnm
# Install dependencies
npm install
# Run locally
npm startScripts
npm start- Run the CLI tool
Contributing
This repository is open for downloads and forks only. Pull requests are not accepted.
Feel free to fork this project and customize it for your own needs!
License
MIT License - see LICENSE file for details
Repository
- GitHub: https://github.com/zandd/pnm
- NPM: @zandd/pnm
Author
zandd
Changelog
1.0.0
- Initial release
- Recursive scanning for node_modules directories
- Size and file count analysis
- Safe deletion with confirmation
- Dry run mode
- Colorful CLI interface
⚠️ Warning: This tool permanently deletes directories. Always review the summary before confirming deletion. Use --dry-run first if you're unsure.
