Developer cleanup

How to Clear npm, pnpm, and Yarn Caches Without Breaking Your Projects

Tell global package caches apart from node_modules, clear npm, pnpm, and Yarn caches with their official commands, and avoid a few common traps.

Published 2026/10/29By WashBear Team

The more dependencies you install, the bigger the caches your package managers collect in your home folder; several gigabytes, sometimes tens of gigabytes, is common. These caches are designed to be deletable, and the worst case is usually re-downloading packages on the next install. In a few situations, though, they are more than a cache. Below are the locations, commands, and caveats for npm, pnpm, and Yarn.

A cache is not node_modules

A global cache is a local copy of packages the package manager has downloaded. All projects share it, and deleting it does not change any project files. node_modules holds the dependencies actually installed in each project; delete it and the project must be installed again before it runs. This article covers the former. To clean up node_modules in old projects in bulk, see cleaning build folders in old projects.

Where the caches live

ToolDefault location on macOS
npm~/.npm/_cacache; tools installed temporarily by npx live in ~/.npm/_npx
pnpmStore in ~/Library/pnpm/store, metadata cache in ~/Library/Caches/pnpm
Yarn 1~/Library/Caches/Yarn
Yarn 2 and laterGlobal cache, enabled by default, in ~/.yarn/berry/cache
Bun~/.bun/install/cache
Corepack~/.cache/node/corepack

If you changed any of these in your configuration, trust the location each tool reports; the commands below show you how to check.

What to know before you clean

  • Packages are downloaded again: after you clear a cache, the next install fetches everything from the network again. Think twice if you work offline, have a slow connection, or depend on a private registry.
  • pnpm space is shared: on APFS disks, pnpm places store files into projects as copy-on-write clones by default, so a project's node_modules and the store share the same data blocks. Deleting only one side may free less space than the size shown.
  • Global installs may depend on the store: according to the pnpm documentation, recent versions run packages installed with pnpm add -g through a links folder inside the store by default, so deleting the whole store means reinstalling those global tools. The same applies to Bun's globalStore (off by default) when enabled: affected projects need bun install again.
  • Yarn PnP projects read straight from the cache: Yarn projects using Plug'n'Play have no node_modules; their dependencies are the zip files in the cache. After clearing the cache, run yarn install before starting such a project.

Manual cleanup commands

npm

# Show the cache root; the default is ~/.npm
npm config get cache
du -sh ~/.npm/_cacache ~/.npm/_npx
# Verify the cache and garbage-collect unneeded data without clearing it
npm cache verify
# Clear the _cacache download cache; node_modules in your projects is untouched
npm cache clean --force
# Remove tools installed temporarily by npx; they are downloaded again on the next run
rm -rf ~/.npm/_npx

npm's cache is self-healing, and the npm documentation says there is no reason to clear it other than reclaiming disk space. If an install fails, try npm cache verify first.

pnpm

# Show the current store location, for example ~/Library/pnpm/store/v10
pnpm store path
du -sh "$(pnpm store path)"
# Remove only packages that no project references
pnpm store prune
# The metadata cache can be deleted outright; pnpm downloads it again as needed
rm -rf ~/Library/Caches/pnpm

The pnpm documentation notes that pnpm store prune has no side effects on your projects and recommends running it occasionally, not too often, because packages you just removed may be needed again soon. pnpm uses one store per disk: for projects on an external disk, the store is usually .pnpm-store at the root of that disk, and running pnpm store path inside such a project shows it.

Yarn

Yarn 1 and Yarn 2+ use different commands, so first run yarn --version to see which version is active in the current directory.

# Yarn 1: show and clear the global cache
yarn cache dir
yarn cache clean
# Yarn 2 and later: run inside a project that uses it; clears only the global cache
yarn cache clean --mirror

yarn cache clean --all also deletes the current project's local cache. If a project commits .yarn/cache to its repository (Zero-Installs), do not use --all in that project.

Bun and Corepack

# Show Bun's global cache location
bun pm cache
# Clear Bun's global cache
bun pm cache rm
# Remove package manager versions downloaded by Corepack; they are fetched again when used
rm -rf ~/.cache/node/corepack

Clean up with WashBear

A Standard Scan in Deep Cleanup checks the default locations of these caches and lists them in two categories, depending on where they live:

  • Developer tools: npm download cache, npx temporary tools, and Bun package cache.
  • User cache files: pnpm store cache (the store plus the metadata cache), Yarn download cache (the global caches of Yarn 1 and Yarn 2+), node-gyp build cache, and Node.js tooling cache for downloads by Corepack, Electron, and similar tools. These items include folders under ~/Library/Caches, which is why they appear here.

Smart recommendation preselects the npm, npx, and node-gyp items; select the pnpm store, Yarn, Bun, and the Node.js tooling cache yourself if you want them. WashBear deletes the entire cache or store folder, which amounts to a full clear, not a pnpm store prune that removes only unreferenced packages. If you rely on pnpm global installs or have Yarn projects using PnP, read the caveats above before selecting these items.

Note

WashBear only checks default locations, so caches you moved elsewhere and pnpm stores on other disks are not found. node_modules folders inside projects belong to the Project build artifacts category and are never preselected. Cleanup deletes files directly instead of moving them to the Trash, and the result is recorded in Operation History.

To see how large these caches are on your Mac, download WashBear and run a scan; scanning alone never deletes anything. The demo below uses sample data, so its items, categories, and selections are only illustrative.

Deep Cleanup

Macintosh HD32.76 GB available
Found 33 cleanable itemsestimated cleanable data79.3 GB
System caches
Selected / Found554 MB/ 554 MBSelect all
Old diagnostic logsLow riskOld diagnostic reports from macOS and apps 313 MB
Long-unused system cachesLow riskSystem caches not updated by you for over 7 days 241 MB
Old temporary filesLow riskTemporary files left behind by macOS and apps 394 KB
Selected items21Estimated release41.5 GB
Selection
Interactive demo · all data is simulated

FAQ

Will my projects still work after I clear the caches?

Yes. Dependencies are already installed in each project's node_modules, and deleting a global cache does not change them; the next install just spends more time downloading. The exceptions are the Yarn PnP projects and pnpm global tools that run from the store, as described above.

How often should I clear them?

There is no need to clear them on a schedule. Clear them when your disk is tight, or run pnpm store prune and npm cache verify every few months.

Why did deleting the pnpm store free less space than expected?

Because node_modules folders you still use reference the same data blocks. Remove node_modules from old projects you no longer use, and that space is actually released.

Related articles