Zyzle.dev

Prune `node_modules` recursively

11th June, 2023

I often find myself running out of space on my old Macbook and one of the simplest ways I've found to deal with this is to remove node_modules directories that I'm not needing at that exact moment in time.

This code can remove all instances of node_modules beneath the directory it's run in, and can be changed to do the same for any other build dir that you might not need:

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