Package managers keep a copy of everything they download so the next install is faster. These caches are shared by all your projects, they rarely clean themselves up, and they are safe to clear. Here is where each one lives on macOS and how to clear it properly.
| Tool | Cache location | Clear with |
|---|---|---|
| npm | ~/.npm/_cacache | npm cache clean --force |
| Yarn 1 | ~/Library/Caches/Yarn | yarn cache clean |
| Yarn 2+ | ~/.yarn/berry/cache | yarn cache clean --all |
| pnpm | ~/Library/pnpm/store | pnpm store prune |
| Cargo | ~/.cargo/registry, ~/.cargo/git | delete by hand |
| pip | ~/Library/Caches/pip | pip3 cache purge |
To see several sizes at once (folders you don't have are reported as missing):
du -sh ~/.npm/_cacache ~/Library/Caches/Yarn ~/.yarn/berry/cache ~/Library/pnpm/store ~/.cargo/registry ~/.cargo/git ~/Library/Caches/pip
npm config get cache prints the cache folder, ~/.npm by default. The package data is in ~/.npm/_cacache.
du -sh ~/.npm/_cacache
npm cache clean --force
npm asks for --force because it considers the cache self-healing. npm cache verify is the gentler option: it checks the cache and removes data it no longer needs.
Yarn 1 (classic) keeps its cache in ~/Library/Caches/Yarn. yarn cache dir prints the exact path and yarn cache clean empties it.
Yarn 2 and later keep a global cache in ~/.yarn/berry/cache by default. yarn cache clean --all clears it.
Be careful with a .yarn/cache folder inside a project. In projects that use Yarn's zero-installs, that folder is committed to git and the project needs it.
pnpm keeps one content-addressable store for all projects. pnpm store path prints its exact location, such as ~/Library/pnpm/store/v10.
du -sh "$(pnpm store path)"
pnpm store prune
pnpm store prune removes packages that no project references. Because each project's node_modules is hard-linked to the store, deleting the store by hand frees less than its size suggests; prune is the intended way. pnpm also keeps a metadata cache in ~/Library/Caches/pnpm, which is safe to delete.
Cargo's download cache is in ~/.cargo/registry: index (the registry index), cache (downloaded .crate files) and src (unpacked sources). Git dependencies are in ~/.cargo/git.
du -sh ~/.cargo/registry/* ~/.cargo/git
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/src ~/.cargo/git
Cargo has no stable command for clearing these, so deleting by hand is the usual way. Keeping index means Cargo doesn't fetch the index again from scratch.
Never delete ~/.cargo/bin. It holds tools you installed with cargo install and, with rustup, the cargo and rustc commands themselves. Leave ~/.cargo/config.toml and ~/.cargo/credentials.toml alone too.
pip3 cache dir
pip3 cache info
pip3 cache purge
The cache is in ~/Library/Caches/pip. Clearing it doesn't touch installed packages or your virtual environments. Use pip instead of pip3 if that is what your setup calls it.
Nothing in your projects changes. The next install downloads what it needs again, so it needs a network connection and is slower than usual the first time. Offline installs that relied on the cache won't work until it fills back up.
npm root -g prints, and ~/.cargo/bin. These are installed tools, not caches.~/.rustup (your Rust toolchains) and Python virtual environments.~/.npmrc and ~/.yarnrc.yml, which may hold registry auth tokens.The free scan in SymbolSweep measures these caches and sorts them by tier:
~/.npm/_cacache, ~/.yarn/cache, ~/.bun/install/cache, ~/.cargo/registry, and in ~/Library/Caches the pnpm, pip, node-gyp, typescript, Homebrew, go-build and CocoaPods folders.~/Library/pnpm/store, with a pointer to pnpm store prune.~/Library/Caches/Yarn, Yarn 2+'s ~/.yarn/berry/cache or ~/.cargo/git. Use the commands above for those.Scanning is free and never deletes anything. Deleting needs a one-time $12 license for one Mac. Requires macOS 13 or later on Apple silicon. See how it works.
Yes. It is a download cache. npm fetches anything it needs again on the next install. Use npm cache clean --force, or npm cache verify for a gentler clean.
No. Project node_modules folders, global packages, virtual environments and Cargo-installed tools are stored elsewhere and stay put.
Not the whole folder. ~/.cargo/registry and ~/.cargo/git are caches, but ~/.cargo/bin holds your installed tools and, with rustup, cargo and rustc themselves.
Ask the tool: npm config get cache, yarn cache dir, pnpm store path and pip3 cache dir. Cargo always uses ~/.cargo unless CARGO_HOME is set.