How to Clean Up Your node_modules Folders with "npx npkill"
Working on lots of JavaScript projects? Your computer is probably stuffed with massive node_modules folders eating up your disk space. Let's look at how to clean them up easily with a tool called npkill.
Why node_modules Are a Pain
If you build websites or apps with JavaScript, you know the drill:
- Every project gets its own huge
node_modulesfolder - These folders are chunky - often 200MB to 500MB each
- Old projects you forgot about still hog your disk space
- Finding and deleting them by hand is boring and takes forever
What's npkill?
npkill is a simple tool that finds and helps you delete node_modules folders with just a few keystrokes.
How to Use npkill
Step 1: Run the Tool
The easiest way is to use npx, which lets you run it without installing anything:
npx npkillThis starts looking from where you are. To scan a specific folder:
npx npkill -d ~/projectsStep 2: Check Out What It Finds
npkill shows you a list with:
- All the
node_modulesfolders it found - How much space each one takes up
- When you last used them
- Easy controls to delete them

Step 3: Delete What You Don't Need
It's super easy to clean up:
- Use up/down arrows to move through the list
- Hit
SPACEto mark a folder you want to delete - Press
dto delete the folder right away - Press
qto quit when you're done
Cool Tricks
npkill can do more than just find node_modules:
See biggest folders first
npx npkill --sort-by sizeSkip folders you want to keep
npx npkill -e vendor,backupDelete other folders too: Like dist or build folders
npx npkill -f dist,buildTips for Better Cleanup
- Look at the dates - If you haven't touched a project in months, it's safe to delete
- Don't worry about mistakes - You can always run
npm installlater if you need those files again - Do this every few months - Make it a habit when your disk gets full
For projects you're still using, try:
npm pruneThis cleans up unused stuff without deleting everything
That's it!
With npkill, you can free up tons of space in just a few minutes. It's amazing how much disk space you can get back by cleaning up these folders!
Next time your computer slows down or you get a "disk full" message, give npkill a try - your computer will thank you!