I ended up here looking to delete my node_modules
folders before doing a backup of my work in progress using rsync
. A key requirements is that the node_modules
folder can be nested, so you need the -prune
option.
First I ran this to visually verify the folders to be deleted:
find -type d -name node_modules -prune
Then I ran this to delete them all:
find -type d -name node_modules -prune -exec rm -rf {} \;
Thanks to pistache