Dec 21, 2023

TIL: Recursively clean up JavaScript projects

I found that my projects folder was taking up 50GB (?!?!).

Here's how to erase node_modules and .next recursively to free it all up:

# do a safe delete using the trash cli
brew install trash
# show me what you're about to do
find . -name 'node_modules' -type d -prune
find . -name node_modules -type d -prune -exec trash {} +
# show me what you're about to do... again
find . -name '.next' -type d -prune
find . -name ".next" -type d -prune -exec trash {} +

From 50 to 5 GB. That is so much better. Maybe next time I'll just use Yarn.