How To Clean All Your node_modules Inside Your Machine

Tue Dec 24 2019

If you worked with javascript for quite some time, you probably have many projects spread around your computer. Recently my mac is super low on memory and I could not find anything to remove.

So I started "debugging" through my folders and I noticed a lot of MBs inside all my projects node_modules.

In the bottom line I removed 30 GB !

# this will output the memory size node_modules take
find . -name "node_modules" -type d -prune -print | xargs du -chs

# this will remove all node_modules
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;