How to clear package manager caches on Mac
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
| Tool | Cache location on macOS | Clean it with |
|---|---|---|
| npm | ~/.npm/_cacache | npm cache clean --force |
| pnpm | ~/Library/pnpm/store (pnpm store path) | pnpm store prune |
| Yarn 1 | ~/Library/Caches/Yarn | yarn cache clean |
| Yarn 2+ | ~/.yarn/berry/cache | yarn 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/CocoaPods | pod cache clean --all |
| Go modules | ~/go/pkg/mod | go clean -modcache |
| Cargo | ~/.cargo/registry | Delete ~/.cargo/registry/cache and ~/.cargo/registry/src |
| Gradle | ~/.gradle/caches | Delete 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:
pnpm store pruneremoves packages no project on your Mac references.uv cache pruneremoves unused entries and keeps the rest;uv cache cleanempties everything.brew cleanupon its own removes old versions and downloads older than 120 days; add-nto preview, and--prune=allto clear every download.pip cache listshows what's cached;pip cache remove <name>removes one package.
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 freeFrequently 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.