How to delete all node_modules from a directory

Sometimes we need to clear all node_modules and free up space on our computer, with that command you can do that:

find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +

Better, using your bash file config, like .zshrc, we can set a new alias:

alias clearpackages="find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +"

Now, just navigate to your directory, and run the command.

cd ~/Projects/