How to clear the npm, pnpm, yarn and Homebrew caches
npm, pnpm, yarn and Homebrew keep every package you've ever downloaded. None of them clean up on their own. On a real Mac, the npm cache alone was 5.3 GB and the pnpm store 6.1 GB.
npm
SafeThe cache lives in ~/.npm. To clear it:
npm cache clean --forcepnpm
Safepnpm store prune removes only packages no project is using. Your projects keep working.
pnpm store pruneyarn
Safeyarn cache cleanHomebrew
SafeRemoves downloaded installers and old versions. Note: if every package has only one version installed, it may free nothing. Don't be surprised if you gain zero.
brew cleanup -s --prune=allWhat to expect afterwards
Your next install downloads whatever is missing, so it takes a bit longer. That's the only change.
FAQ
Is npm cache clean --force dangerous?
No. The --force flag is only there because npm asks you to confirm. It deletes the download cache, not your projects or globally installed packages.
Keep reading
How to find and delete old node_modules on Mac
Find every node_modules folder on your Mac, sort them by size and delete the ones from inactive projects. They reinstall with one command.
How to safely clear the cache on your Mac
What your Mac's cache is, how much space it takes and how to clear it without breaking anything. Steps for Finder and Terminal.