← All guides

Find and delete every node_modules on your Mac

CacheCleaner guides · Updated July 18, 2026

Deleting node_modules is always safe. It contains only downloaded packages listed in the project's lockfile – npm install (or pnpm/yarn/bun) restores it exactly. Every project you cloned once and forgot still carries 200 MB–2 GB of it.

List them all, biggest first

find ~ -name node_modules -type d -prune -exec du -sh {} + 2>/dev/null | sort -rh | head -30

-prune stops find from descending inside each match, so nested node_modules aren't double-counted and the scan is fast.

Delete the ones you don't need

rm -rf ~/old-project/node_modules

Or wipe all of them under an archive folder you no longer touch:

find ~/Archive -name node_modules -type d -prune -exec rm -rf {} +

Don't forget the package manager caches

npm, pnpm, yarn and bun each keep a global download cache on top of per-project folders – often another 5-20 GB:

npm cache clean --force
pnpm store prune
yarn cache clean
bun pm cache rm

CacheCleaner scans your whole disk for node_modules, Rust target, SwiftPM .build, Gradle builds and virtualenvs, shows every one with its size, and deletes only what you tick – plus the global npm/pnpm/yarn/bun caches in the same pass.

Get CacheCleaner for Mac