Where the caches live and how to clear them
npm keeps its cache in ~/.npm. Check its size and clear it:
du -sh ~/.npm
npm cache clean --forceYarn (classic) caches in ~/Library/Caches/Yarn:
yarn cache cleanpnpm uses a content-addressable store in ~/Library/pnpm/store; prune unreferenced packages with:
pnpm store pruneClearing a package manager cache is always safe: the worst case is that the next install re-downloads packages from the registry. Note that pnpm is the exception where blunt deletion is a bad idea — projects hard-link into the store, so use pnpm store prune rather than deleting the folder.
The caches people forget
npm is rarely the biggest offender. On a typical development Mac these also accumulate for years:
- Homebrew:
brew cleanup --prune=all(cache in~/Library/Caches/Homebrew) - pip:
pip cache purge - CocoaPods:
pod cache clean --all - Gradle:
~/.gradle/caches— often several GB - Cargo (Rust):
~/.cargo/registry - Go:
go clean -modcache - Xcode DerivedData — usually the single largest one; see our DerivedData guide.
Checking them all at once
RepoSweep scans every one of these well-known cache locations in a single pass — npm, Yarn, pip, Homebrew, CocoaPods, Swift Package Manager, Go, Playwright, Gradle, Maven, Cargo, and Xcode — shows how big each is and how it regenerates, and moves what you select to macOS Trash so it stays reversible. Scanning is free without limits; see pricing for cleanup.