node-janitor
v1.2.1
Published
๐งน Smart CLI tool to clean up node_modules folders - free up disk space automatically
Downloads
505
Maintainers
Readme
๐งน Node-Janitor
Smart CLI tool to clean up
node_modulesfolders - free up disk space automatically
โจ Features
- ๐ Smart Scanner - Find all
node_modulesin your system - โฐ Time-based Cleanup - Delete folders older than X days
- ๐งผ Deep Clean - Remove unnecessary files (docs, tests, source maps)
- ๐๏ธ Dry Run - Preview before deleting
- ๐ฎ Interactive Mode - Step-by-step wizard
- ๐พ Backup - Save list before deletion
- ๐ Reports - Detailed analytics
- โก Fast Mode - Native OS commands for speed
- ๐ CI/CD Ready - Silent mode with JSON output
- โ๏ธ Config File - Persistent settings with
.janitorrc - ๐ Git-aware - Skip repos with uncommitted changes
- ๐ Multi-language - 8 languages supported
- ๐ Watch Mode - Continuous monitoring
- ๐ Scheduled Cleanup - Cron-style automation
๐ฆ Installation
# Global installation
npm install -g node-janitor
# Or use with npx
npx node-janitor๐ Quick Start
# Scan current directory
node-janitor
# Scan specific path
node-janitor --path ~/projects
# Preview what would be deleted (dry run)
node-janitor --path ~/projects --dry-run
# Delete folders older than 30 days
node-janitor --older-than 30d
# Interactive mode
node-janitor --interactive๐ฅ๏ธ Interactive TUI Mode (NEW!)
Launch a full-screen, keyboard-navigable interface similar to npkill:
# Start TUI mode
node-janitor --live
# Or use the tui subcommand
node-janitor tui --path ~/projectsFeatures:
- โจ๏ธ Keyboard Navigation - Use arrow keys or j/k to navigate
- โ๏ธ Multi-select - Press SPACE to select/deselect folders
- ๐ Sort toggle - Press S to switch between size/age sorting
- ๐จ Color-coded - Green (new), Yellow (medium), Red (old)
- ๐๏ธ Quick delete - Press D to delete selected folders
- ๐ Real-time stats - See total size and selection count
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐งน NODE JANITOR - Interactive Mode โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๐ Found: 15 folders | Total: 2.5 GB | Selected: 3 (523 MB) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ > โ ~/projects/old-app/node_modules 523 MB 180 days โ
โ โก ~/projects/test-project/node_modules 312 MB 95 days โ
โ โ ~/projects/archived/node_modules 245 MB 45 days โ
โ โก ~/projects/client-work/node_modules 198 MB 30 days โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ [โ/โ] Navigate [SPACE] Select [A] All [S] Sort [D] Delete โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐ Usage
Basic Commands
# Scan and show all node_modules
node-janitor --path ~/projects
# Limit scan depth
node-janitor --path ~/projects --depth 3
# Quick scan (skip size calculation)
node-janitor --path ~/projects --quickTime-based Cleanup
# Delete folders older than 30 days
node-janitor --older-than 30d
# Delete folders older than 3 months
node-janitor --older-than 3m
# Delete folders between 30-90 days old
node-janitor --between 30d-90dSize Filters
# Only delete folders larger than 500MB
node-janitor --min-size 500MB
# Only delete folders smaller than 10MB
node-janitor --max-size 10MBDeep Clean Mode
Remove unnecessary files from node_modules without deleting the entire folder:
node-janitor --deep-cleanFiles removed:
- Documentation:
*.md,LICENSE,CHANGELOG,docs/ - Tests:
test/,tests/,__tests__/,spec/ - Source maps:
*.map - Examples:
example/,examples/ - Config files:
.eslintrc,.prettierrc, etc.
Safe Mode
# Preview without deleting
node-janitor --dry-run
# Create backup before deletion
node-janitor --backup
# Only delete if lockfile exists
node-janitor --lock-checkPerformance
# Use native OS commands (faster)
node-janitor --fast
# Parallel deletion
node-janitor --parallel 4Reports
# Generate report
node-janitor report
# Detailed report
node-janitor report --detailed
# JSON output
node-janitor report --jsonCI/CD Integration
# Silent mode (no prompts, no colors)
node-janitor --silent --older-than 30d
# JSON output for automation
node-janitor --jsonExclude Patterns
# Exclude specific folders
node-janitor --exclude "important-project,client-work"
# Include only matching patterns (whitelist)
node-janitor --include "work-*,client-*"Git-aware Cleanup
# Skip repos with uncommitted changes
node-janitor --skip-dirty-git
# Only process folders inside git repos
node-janitor --git-onlyConfig File
Create .janitorrc in your home directory or project:
{
"exclude": ["important-project"],
"defaultOlderThan": "30d",
"defaultPath": "~/projects",
"lang": "vi"
}Use custom config:
node-janitor --config ~/.my-janitor-config.jsonMulti-language Support
# Vietnamese
node-janitor --lang vi
# Chinese
node-janitor --lang zh
# Japanese
node-janitor --lang ja
# Available: en, vi, zh, ja, ko, es, fr, deWatch Mode
Continuously monitor and clean:
# Watch with 60s interval
node-janitor watch --interval 60 --older-than 30d
# Auto-clean when found
node-janitor watch --auto-clean --older-than 60dScheduled Cleanup
Cron-style scheduling:
# Daily cleanup at midnight
node-janitor schedule --daily --older-than 30d
# Weekly on Sunday
node-janitor schedule --weekly
# Custom cron expression
node-janitor schedule --cron "0 0 * * *" --older-than 60d๐ All Options
| Option | Description |
|--------|-------------|
| -p, --path <path> | Directory to scan (default: current) |
| -d, --depth <n> | Maximum scan depth |
| --older-than <duration> | Only process folders older than (30d, 3m, 1y) |
| --between <range> | Age range (30d-90d) |
| --min-size <size> | Minimum folder size (500MB) |
| --max-size <size> | Maximum folder size (10MB) |
| --dry-run | Preview only |
| --deep-clean | Remove unnecessary files |
| --fast | Use native OS commands |
| --parallel <n> | Number of parallel deletions |
| --backup | Create backup before deletion |
| --lock-check | Only delete if lockfile exists |
| --quick | Skip size calculation |
| -i, --interactive | Interactive mode |
| -v, --verbose | Verbose output |
| --debug | Debug mode |
| --silent | Silent mode (CI/CD) |
| --json | JSON output |
| --exclude <patterns> | Exclude patterns (comma-separated) |
| --include <patterns> | Include only matching patterns |
| -c, --config <path> | Config file path |
| --skip-dirty-git | Skip repos with uncommitted changes |
| --git-only | Only process git repos |
| --lang <code> | Language (en, vi, zh, ja, ko, es, fr, de) |
๐ฏ Examples
Clean old projects
# Find and delete node_modules older than 90 days
node-janitor --path ~/projects --older-than 90dDeep clean to save space
# Remove docs, tests, source maps from all node_modules
node-janitor --path ~/projects --deep-cleanCI/CD cleanup
# Automated cleanup in CI
node-janitor --silent --older-than 60d --jsonCautious cleanup
# Preview first
node-janitor --path ~/projects --older-than 30d --dry-run
# Then execute with backup
node-janitor --path ~/projects --older-than 30d --backup๐ Sample Output
๐งน NODE JANITOR
โ Found 15 node_modules folders
โโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโ
โ # โ Path โ Size โ Age โ Packages โ Lock โ
โโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโโโผโโโโโโโค
โ 1 โ ~/projects/old-app โ 523 MB โ 180d โ 1,234 โ npm โ
โ 2 โ ~/projects/test-project โ 312 MB โ 95d โ 567 โ yarn โ
โ 3 โ ~/projects/archived โ 245 MB โ 45d โ 890 โ npm โ
โโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโโโดโโโโโโโ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโ
โ Total Folders โ 15 โ
โ Total Size โ 2.5 GB โ
โ Oldest โ 180 days โ
โ Newest โ 5 days โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโ๐ง Development
# Clone repository
git clone https://github.com/patchybean/node-janitor.git
cd node-janitor
# Install dependencies
npm install
# Build
npm run build
# Run locally
node dist/index.js --help๐ License
MIT ยฉ Patchy Bean
Made with โค๏ธ for developers who hate bloated disk space
