Quick way to delete old node_modules folders

Utkarsh Shigihalli
1 min readJan 24, 2024

Recently I filled the storage space on my Mac and upon scanning, I found the majority of the size was due to the dreaded node_modules folders scattered all across my machine.

I needed a quicker way to clean all the node_modules folders and keep the folder for active projects I was working on. It was too much work for me to cd into individual folders and delete folders.

That is when I found npkill the command. You do not need to install the tool, just run

npx npkill -s size

This command by default scans all the node_modules folders under the current directory and with -s size flag, I was able to sort them based on the folder size.

Deleting the folder is just pressing the spacebar key and it will delete the folder immediately.

Just like that, I was able to restore the lost space on my Mac.



Utkarsh Shigihalli

Microsoft MVP | Developer | Passionate about Cloud, .NET and DevOps