dnms
v0.1.4
Published
A fast and efficient CLI tool to find and delete `node_modules` directories recursively, helping you reclaim valuable disk space from your development projects.
Readme
🗑️ Node Modules Cleaner
A fast and efficient CLI tool to find and delete node_modules directories recursively, helping you reclaim valuable disk space from your development projects.
Built with Bun for maximum performance.
✨ Features
- 🚀 Blazing Fast: Leverages Bun's native APIs for optimal performance
- 🔍 Recursive Scanning: Automatically finds all
node_modulesdirectories in a given path - 📊 Size Calculation: Shows how much disk space each directory occupies
- 🛡️ Safe by Default: Multiple safety modes to prevent accidental deletions
- 🎨 Beautiful CLI: Colorful, intuitive terminal interface
- ⚡ Efficient Deletion: Uses optimized methods for fast removal
📦 Installation
bun install🚀 Usage
Run Without Install
With Bun:
bunx dnms --scanWith npm:
npx dnms --scanBasic Commands
Scan directories without deleting:
bunx dnms --scanScan a specific directory:
bunx dnms --scan ~/projectsDry run (see what would be deleted):
bunx dnms --dry-runDelete with confirmation prompts:
bunx dnms --confirmVerbose output:
bunx dnms --verbose --scanCommand-Line Options
| Option | Short | Description |
|--------|-------|-------------|
| --scan | -s | Scan only mode - finds node_modules without deleting |
| --dry-run | -d | Shows what would be deleted without actually deleting |
| --help | -h | Display help message with usage instructions |
| --verbose | -v | Enable detailed output with progress indicators |
| --confirm | -c | Ask for confirmation before each deletion |
Examples
Find all node_modules in your projects directory:
bunx dnms --scan ~/Documents/projectsFind all node_modules using the CLI name:
bunx dnms --scan ~/Documents/projectsDelete all node_modules with individual confirmation:
bunx dnms --confirm ~/Documents/projectsPreview deletion with detailed output:
bunx dnms --dry-run --verbose .🔒 Safety Features
- Confirmation Prompt: By default, asks for confirmation before starting deletion
- Scan Mode: Preview what will be found before taking action
- Dry Run Mode: See exactly what would be deleted
- Per-Item Confirmation: Use
--confirmto approve each deletion individually - Graceful Ctrl+C: Cleanly exits on keyboard interrupt
📊 Output Example
╔══════════════════════════════════════════════════════════╗
║ 🗑️ Node Modules Cleaner 🗑️ ║
║ Clean up disk space efficiently ║
╚══════════════════════════════════════════════════════════╝
Mode: SCAN
Target: /Users/you/projects
Verbose: OFF
🔍 Searching for node_modules directories...
Found: /Users/you/projects/app1/node_modules (245.32 MB)
Found: /Users/you/projects/app2/node_modules (512.18 MB)
Found: /Users/you/projects/api/node_modules (189.45 MB)
============================================================
📊 SUMMARY
============================================================
Found: 3 node_modules directories
Total size: 946.95 MB
💡 Run without --scan to delete these directories
⏱️ Operation completed in 2.34s🛠️ Technical Details
- Built with TypeScript for type safety
- Uses Bun's native APIs for file operations
- Recursive directory traversal with
readdir - Efficient size calculation using
Bun.file()andGlob - Cross-platform compatibility
⚠️ Important Notes
- This tool permanently deletes directories - use with caution
- Always use
--scanfirst to preview what will be found - You can always reinstall dependencies with
bun install,npm install, etc. - The tool skips directories it cannot access
📝 License
This project was created using bun init in bun v1.3.5.
🤝 Contributing
Feel free to open issues or submit pull requests for improvements!
