Fast and efficient tool to reduce node_modules size by up to 60%. Ideal for serverless, Docker, and deployment optimization.
As JavaScript developers, we all know the notorious pain of the node_modules folder – it’s become a gargantuan entity of its own. You clone a simple project, run npm install, and suddenly hundreds of megabytes are consumed. The irony? Most of these files are unnecessary bloat – tests, documentation, and configuration files that never see the light of production. Even with modern package managers like pnpm and Bun, while the situation has marginally improved compared to npm CLI, the fundamental problem persists.
Today, I’m excited to introduce prune-mod – a tool I developed to tackle this exact problem.
Despite being an ultra-lightweight 8.3KB tool, prune-mod can reduce your node_modules size by up to 60% without compromising your application’s functionality.
Key features that set this tool apart:
• Intelligent runtime detection: Automatically leverages Bun if available, boosting processing speed by up to 3x
• Dry-run mode for previewing changes before applying them
• Safety-first approach: Never removes critical files like package.json entry points
• Seamless CI/CD and Docker integration for optimizing image sizes
Usage couldn’t be simpler:
npx @usex/prune-mod
This tool particularly shines in these scenarios:
• Serverless deployments with strict size limitations (I personally faced this challenge on Cloudflare)
• Docker containers where you need faster uploads and pull times
• Local development when you need to reclaim precious disk space
Real-world impact: On a typical Next.js project, we’ve seen reductions from 487MB to 193MB – that’s 60% smaller with 44% fewer files!
The project is open source, and I welcome contributions, feedback, and suggestions from the community.
GitHub: https://github.com/ali-master/prune-mod
NPM: https://www.npmjs.com/package/@usex/prune-mod
I hope this tool proves as valuable to you as it has been for me, reducing daily development friction and accelerating your deployment cycles after every git push.
Let’s make our codebases leaner and our deployments faster together!