How to clear the npm, pnpm, yarn and Homebrew caches

3 min readYou recover: 2–15 GBUpdated: 2026-09-29

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

Safe

The cache lives in ~/.npm. To clear it:

npm cache clean --force

pnpm

Safe

pnpm store prune removes only packages no project is using. Your projects keep working.

pnpm store prune

yarn

Safe
yarn cache clean

Homebrew

Safe

Removes 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=all

What 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