How to Remove all node_modules/ in multiple directories

So today, I am about to make a switch from Debian to Arch. When I installed my Debian, I had not known about installing /etc, /var and others in different partitions. Now I want to backup my /var/www/html which contains most of my project and clients’ to an external drive, but node_modules!!!

There are many node_modules inside each of these projects and I can’t go find them all and delete them so they could be reinstalled with npm install or yarn. I remembered the mighty find 🙂

Run this in the directory

sudo find ./ -type d -name node_modules -exec rm -dr {} +

Watch them all vanish. Cheers! 🙂