Skip to content

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/null

JavaScript: npm, pnpm, Yarn and Bun

  • npm keeps its cache in ~/.npm/_cacache (details). Clear it with npm cache clean --force.
  • pnpm keeps one shared store in ~/Library/pnpm/store (details). pnpm store prune removes only packages no project uses any more.
  • Yarn 1 caches in ~/Library/Caches/Yarn (details); yarn cache clean empties it. Yarn 2 and later keep a global cache in ~/.yarn/berry/cache.
  • Bun caches in ~/.bun/install/cache (details); bun pm cache rm clears 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 purge empties it.
  • uv caches in ~/.cache/uv (details). uv cache clean empties it; uv cache prune keeps what's still in use.
  • Poetry caches in ~/Library/Caches/pypoetry. poetry cache clear --all PyPI clears the PyPI cache.
  • conda keeps package archives in the pkgs folder of your install (details). conda clean --all removes 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/cache is safe; Cargo downloads crates again on the next build. A project's target folder is its build output and is usually far bigger: cargo clean in the project removes it.
  • Go keeps modules in ~/go/pkg/mod (details) and compiled packages in ~/Library/Caches/go-build. go clean -modcache and go clean -cache empty 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.

Hear when DiskCity launches

We'll tell you about new versions and sales, with their end dates.