How to clear package manager caches on Mac

Part of our guide to why System Data is so large on Mac · Updated September 2026 · 5 min read

Every package manager keeps a cache of everything it has ever downloaded, so the next install is fast. None of them clean it by default, and after a year of development the caches together are often 5–30 GB. All of these are safe to clear: the worst case is re-downloading a package the next time you need it.

See how big each cache is

du -sh ~/.npm ~/Library/pnpm ~/Library/Caches/{Yarn,pip,Homebrew,CocoaPods,uv} \
       ~/.cache/uv ~/.cargo/registry ~/go/pkg/mod ~/.gradle/caches 2>/dev/null | sort -hr

Paths that don't exist on your Mac are skipped.

The safe clean command for each

ToolCache location on macOSClean it with
npm~/.npm/_cacachenpm cache clean --force
pnpm~/Library/pnpm/store (pnpm store path)pnpm store prune
Yarn 1~/Library/Caches/Yarnyarn cache clean
Yarn 2+~/.yarn/berry/cacheyarn cache clean --all
pip~/Library/Caches/pip (pip cache dir)pip cache purge
uv~/.cache/uv (uv cache dir)uv cache prune or uv cache clean
Homebrew~/Library/Caches/Homebrew (brew --cache)brew cleanup --prune=all
CocoaPods~/Library/Caches/CocoaPodspod cache clean --all
Go modules~/go/pkg/modgo clean -modcache
Cargo~/.cargo/registryDelete ~/.cargo/registry/cache and ~/.cargo/registry/src
Gradle~/.gradle/cachesDelete the folder with no build running

Gentle first: prune instead of wipe

Some tools can remove only what nothing uses any more, which keeps your next install fast:

What you give up

Nothing permanent. The next install of a package that was cached downloads it again, so the first install after cleaning is slower and needs a connection. Projects that are already installed keep working: their node_modules, virtual environments and build folders don't depend on the global cache (pnpm projects link into the store, so use pnpm store prune rather than deleting the store).

Don't clean caches while an install or build is running. Stop it first, then clean.

Measured sizes of common packages and projects are in our Mac developer storage statistics 2026.

Rather see it all at once? Storage Cleaner finds every package manager cache along with node_modules, venvs, Xcode data and AI models in one scan, shows when you last used each item and whether it's safe to remove, and cleans to the Trash with Undo. Scanning is free.

Try Storage Cleaner free

Frequently asked

Is npm cache clean --force safe? Yes. The --force is required only because npm considers the cache self-healing; it doesn't touch your projects.

Why is my pip cache so big? Machine-learning wheels are large (a PyTorch wheel is over 100 MB), and pip keeps every version you've downloaded.

How often should I clean? Every few months, or when disk space is tight. Cleaning weekly only makes installs slower.