How to clear npm, pnpm, Yarn, pip and Homebrew caches on a Mac
Last updated 28 October 2026
Every package manager keeps a download cache so the next install is faster. None of them clean up on their own, so after a year of projects they often add up to 5 to 20 GB. All of them are safe to clear: the next install downloads what it needs again. Use each tool's own command where it has one, because it knows what's still in use.
See how big your caches are
This adds up the usual suspects in one go. Paths that don't exist on your Mac are skipped:
du -sh ~/.npm ~/Library/pnpm/store ~/Library/Caches/Yarn ~/.bun/install/cache ~/Library/Caches/pip ~/.cache/uv ~/Library/Caches/Homebrew ~/.cargo/registry ~/go/pkg/mod ~/.gradle/caches 2>/dev/nullJavaScript: npm, pnpm, Yarn and Bun
- npm keeps its cache in
~/.npm/_cacache(details). Clear it withnpm cache clean --force. - pnpm keeps one shared store in
~/Library/pnpm/store(details).pnpm store pruneremoves only packages no project uses any more. - Yarn 1 caches in
~/Library/Caches/Yarn(details);yarn cache cleanempties it. Yarn 2 and later keep a global cache in~/.yarn/berry/cache. - Bun caches in
~/.bun/install/cache(details);bun pm cache rmclears it.
These caches are separate from each project's node_modules. For those, see finding and deleting node_modules.
Python: pip, uv, Poetry and conda
- pip caches wheels in
~/Library/Caches/pip(details).pip cache purgeempties it. - uv caches in
~/.cache/uv(details).uv cache cleanempties it;uv cache prunekeeps what's still in use. - Poetry caches in
~/Library/Caches/pypoetry.poetry cache clear --all PyPIclears the PyPI cache. - conda keeps package archives in the
pkgsfolder of your install (details).conda clean --allremoves the ones no environment needs.
Virtual environments (.venv folders) are different: they hold a project's installed packages, and you recreate them from the project's requirements or lock file.
Homebrew
Homebrew keeps downloaded bottles in ~/Library/Caches/Homebrew (details) and old versions of what you've upgraded. brew cleanup removes both; brew cleanup --prune=all also empties the download cache completely. Your installed formulae and apps stay.
Rust, Go and Java
- Cargo downloads crates to
~/.cargo/registry(details). Deleting~/.cargo/registry/cacheis safe; Cargo downloads crates again on the next build. A project'stargetfolder is its build output and is usually far bigger:cargo cleanin the project removes it. - Go keeps modules in
~/go/pkg/mod(details) and compiled packages in~/Library/Caches/go-build.go clean -modcacheandgo clean -cacheempty them. - Gradle caches dependencies in
~/.gradle/caches(details). Stop running builds first (./gradlew --stop), then delete the folder; the next build downloads what it needs. - Maven keeps everything in
~/.m2/repository. It's safe to delete, but every project downloads its dependencies again on the next build, which can take a while.
What to leave alone
Don't clear caches in the middle of an install or build, and keep the caches you rely on offline (on a plane, say) until you're back online. Globally installed tools (npm install -g, pipx, cargo install) aren't caches: remove them with their own uninstall commands if you no longer use them.
The folder library lists 356 caches and folders like these, with where each lives and how it comes back.
How DiskCity handles package caches
DiskCity is in development. It finds these caches automatically, shows their size in the city's Developer district, labels them as rebuildable with how they come back, and clears them through each tool's own command where there is one (pnpm store prune, go clean -modcache, conda clean), only after you approve. Join the waitlist to hear when it launches.
