I have been holding lot of Github repositories based on “NPM” ecosystem, both personal and company projects on my machine. Each repository requires NPM install, obviously. The process takes some space, but since eventually it will be bundled on production I care less. Also, on a different note, I end up backing up my photos to cloud storage from my SSD because of limited space (250 gb). Little did I know that real culprit of “Hard disk space full” notification on my machine was JS Ecosystem. Lets check how much does each “node_module” folder cost.
Here is an awesome tool - NPKILL, that exposes each “node_modules” folder in your system and helps you in the cleanup.
This tool allows you to list any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space. Yay!
Obviously, you will have to install it using
npm install npkill -g, which will create node_modules directory its dependency somewhere in the system 😂😜. Such is npm and JS ecosystem!
As you can check out, 33 Gigs of node_modules. I removed all Github repos which require minimal maintenance and also learnt that in JS ecosystem, your developer machine should be treated like prod machine!
NPKill has lot of options around directory to scan and some reporting settings. By default, npkill will scan for node_modules starting at the path where npkill command is executed.
Official Site: NPKILL