| Crates.io | node-cleaner |
| lib.rs | node-cleaner |
| version | 0.2.24 |
| created_at | 2025-05-27 22:40:04.528096+00 |
| updated_at | 2025-05-27 22:40:04.528096+00 |
| description | A tool for cleaning and managing node_modules directories |
| homepage | |
| repository | https://github.com/Breinss/rust-node-modules-cleaner |
| max_upload_size | |
| id | 1692005 |
| size | 590,958 |

⚠️ Work in Progress - Not yet available via package managers
A lightning-fast CLI tool written in Rust that scans your system for node_modules directories and helps you safely clean them up to reclaim disk space.
JavaScript and Node.js projects are notorious for creating massive node_modules directories that:
node-cleaner is designed to help you identify and safely remove unnecessary files from these directories, reclaiming valuable disk space without breaking your projects.
node-modules-scanner is a high-performance Rust CLI tool that recursively scans your filesystem for node_modules directories and reports on them based on configurable pattern matching rules. It helps you identify:
node_modules directories -- Still unsure on this feature since it will require a greater itteration load, might add it as a possible flagnode_modules are safe to removeBlazing fast scanning powered by Rust's walkdir crate
Configurable pattern matching via JSON configuration
System-wide scanning with intelligent path exclusions
Categorized reporting of files by safety level
Size reporting to identify the largest space consumers
Minimal dependencies for a lightweight installation

# Clone the repository
git clone https://github.com/Breinss/rust-node-modules-cleaner.git
# Navigate to the project directory
cd rust-node-modules-cleaner
# Build the project
cargo build --release
# Optional: Install to your system
sudo cp target/release/node-cleaner /usr/local/bin/
yay -S node-cleaner
# Run a basic scan in the current directory and subdirectories
node-cleaner
# Run with debug output
node-cleaner --debug true
# Enable verbose logging (multiple levels available)
node-cleaner -v # Verbose output
node-cleaner -vv # More detailed output
node-cleaner -vvv # Debug-level output
# Run a full scan (includes more thorough analysis)
node-cleaner --full
✅ Successfully loaded patterns config
📂 Scanning directories...
🔍 Found 42 node_modules directories
💡 Identified 156 files safe to remove (3.2 GB potential savings)
⚠️ Found 23 files requiring caution (0.8 GB)
❌ Found 5 potentially unsafe files (0.1 GB)
Files to clean:
1. /home/user/projects/webapp/node_modules/package/tests (45.2 MB)
2. /home/user/projects/api/node_modules/module/examples (230.5 MB)
...
Would you like to remove these files? [Y/n]
The tool uses a pattern-matching system to identify which files are safe to remove. These patterns are defined in a JSON configuration file.
{
"$default": "safe",
"safe": {
"patterns": [
"readme*",
".npmignore",
"license",
"*.md",
"examples/",
"tests/"
],
"ignore": [
"validate-npm-package-license",
"spdx-license-ids"
]
},
"caution": {
"patterns": [
"*.png",
"*.jpg",
"*.html",
"*.css"
],
"ignore": []
},
"danger": {
"patterns": [
"*.js",
"*.ts",
".bin/",
"dist/"
],
"ignore": []
}
}
Permission Denied Errors
No Files Found
--full flag for a more thorough scanProgram Crashes During Scan
-v flags)If you encounter issues not covered here, please:
Run with -vvv to get debug output
File an issue on GitHub with the full error message and debug output


rust-node-modules-cleaner/
├── src/
│ ├── main.rs # Entry point and main logic
│ ├── config/ # Configuration handling
│ │ ├── mod.rs
│ │ ├── cli.rs # Command-line interface
│ │ ├── config.rs # Configuration loading
│ │ └── patterns.json # Default patterns
│ ├── file_utils/ # File system operations
│ │ ├── mod.rs
│ │ ├── fs_utils.rs # File system utilities
│ │ ├── matcher.rs # Pattern matching
│ │ └── remover.rs # File removal
│ └── utils/ # General utilities
│ ├── mod.rs
│ ├── g_utils.rs # UI helpers
│ └── read_size.rs # Size calculation
├── Cargo.toml # Dependencies
├── PKGBUILD # Arch packaging
└── README.md # This file
# Build for current platform
cargo build --release
# Cross-compile (requires appropriate rust targets)
rustup target add x86_64-unknown-linux-gnu
cargo build --release --target=x86_64-unknown-linux-gnu
cargo test
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)USE AT YOUR OWN RISK: This tool modifies your file system by deleting files and directories. While it's designed to be safe, I am not responsible for any data loss or damage that may occur from using this software.
Remember that node_modules can sometimes contain modified files or custom patches that might be critical to your project.