A blazing-fast tool to analyze and clean up node_modules directories by removing unnecessary files.
node_modules directories often contain unnecessary files that bloat your project size:
- TypeScript source files (
.ts,.tsx) that are only needed during development - Documentation files (
.md) and examples - Source maps (
.map) used for debugging - Test files that aren't needed in production
This tool helps you identify and remove these files, which is especially useful for:
-
🐳 Docker Images - Reduce Docker image size significantly by cleaning
node_modulesbefore building the image. Smaller images mean:- Faster deployment and scaling
- Reduced storage costs
- Quicker CI/CD pipelines
- Lower bandwidth usage
-
☁️ Serverless Functions - Stay within size limits and improve cold start times
-
💾 Storage Optimization - Free up disk space on development machines and CI/CD runners
-
📦 Distribution - Smaller package sizes for faster downloads and installations
A typical node_modules folder can be reduced by 30-50% by removing development-only files. For a 500MB node_modules, that's 150-250MB saved per Docker image!
- 🔍 Analyze - Scan your
node_modulesto see how much space can be freed - 🧹 Clean - Remove unnecessary files (
.ts,.tsx,.md,.html,.map, test files) - ⚡ Fast - Built with Rust for maximum performance
- 🛡️ Safe - Only removes non-essential files that aren't needed for runtime
cargo install --path .Or build from source:
cargo build --releaseThe binary will be available as nmz in target/release/.
See how much space can be freed without making any changes:
nmz --analyzeWith custom path:
nmz --analyze --path ./my-project/node_modulesRemove unnecessary files from node_modules:
nmzWith custom path:
nmz --path ./my-project/node_modulesThe tool removes the following file types that are typically not needed in production:
*.ts- TypeScript source files*.tsx- TypeScript JSX files*.md- Markdown documentation*.html- HTML files*.map- Source map files*.test.*- Test files
┌──────────┬─────────────┬────────────┐
│ Pattern │ Files count │ Total size │
├──────────┼─────────────┼────────────┤
│ *.ts │ 1245 │ 45.2 MB │
│ *.tsx │ 342 │ 12.8 MB │
│ *.md │ 892 │ 3.4 MB │
│ *.html │ 156 │ 892.5 KB │
│ *.map │ 2341 │ 89.7 MB │
│ *.test.* │ 567 │ 23.1 MB │
└──────────┴─────────────┴────────────┘
we can safely reduce the size of the node_modules folder by 174.3 MB
Built with Rust and optimized for speed:
- 🔄 Parallel file processing with Rayon
- 🎯 Efficient glob pattern matching
- 🚀 LTO and strip optimizations enabled in release builds
Contributions are welcome! Please feel free to submit a Pull Request.