How to clear npm, Yarn, pnpm and Bun caches on Mac
Updated November 24, 2026
JavaScript package managers keep a copy of every package version you've ever installed, and every project keeps its own node_modules. On a busy developer Mac that's commonly 10–40 GB. All of it can be downloaded again, so it's safe to clear.
Check the sizes first
du -sh ~/.npm ~/Library/Caches/Yarn ~/.yarn/berry/cache ~/Library/pnpm/store ~/.bun/install/cache 2>/dev/null
Folders that don't exist are simply skipped.
npm Safe
npm's cache lives in ~/.npm/_cacache. Clear it with:
npm cache clean --force
The --force is required because npm considers the cache self-healing and normally refuses. ~/.npm/_npx (packages fetched by npx) and ~/.npm/_logs are also safe to delete.
Yarn Safe
Yarn 1 (classic) stores its cache in ~/Library/Caches/Yarn. Check the exact path with yarn cache dir, then:
yarn cache clean
Yarn 2+ (Berry) keeps a shared cache in ~/.yarn/berry/cache. From any Yarn Berry project run:
yarn cache clean --mirror
Careful Some Yarn Berry projects commit their .yarn/cache folder to Git ("zero-installs"). Don't delete a project's .yarn/cache by hand; the global cache above is fine.
pnpm Safe
pnpm uses one content-addressable store shared by all projects (on macOS usually ~/Library/pnpm/store; check with pnpm store path). Remove packages no project references anymore:
pnpm store prune
This is the recommended way; it keeps packages your current projects still use, so installs stay fast.
Bun Safe
bun pm cache rm
Bun's cache is in ~/.bun/install/cache.
The bigger win: old node_modules folders
Each project's node_modules is often 300 MB–1 GB, and old projects you haven't touched in months still have theirs. List them (change ~/Projects to wherever you keep code):
find ~/Projects -name node_modules -type d -prune -exec du -sh {} + | sort -h
Delete the ones for projects you're not working on. Running npm install (or yarn / pnpm install) brings them back when you return to a project. The open-source tool npx npkill gives you an interactive list to delete them one by one.
Framework build caches are safe to delete the same way: .next, .nuxt, .svelte-kit, .turbo, .parcel-cache and .angular.
Other caches JavaScript tools leave
- node-gyp headers:
~/Library/Caches/node-gyp— safe. - Puppeteer browsers:
~/.cache/puppeteer— safe, re-downloaded on next install. - Playwright browsers:
~/Library/Caches/ms-playwright— re-download withnpx playwright install; delete only if you can spare the time.
How MacDejunk handles Node
MacDejunk measures all of these caches and finds node_modules and framework build folders inside your project folders, showing the project each belongs to and when you last touched it, so you can clear old projects without hunting through Finder.
Do it in one click with MacDejunk
MacDejunk is a free Mac app that finds this junk (and the rest of what Xcode, Android, Node, Flutter and Homebrew leave behind), shows what's safe to delete, and frees the space. Everything stays on your Mac.
Download MacDejunk — free