Every JavaScript package manager keeps a copy of each package it downloads, and none of them trims it on its own. After a year of projects the npm cache is 2 to 10 GB, the pnpm store 5 to 30 GB, and Yarn and Bun a few GB each.
All of these caches are safe to clear: the next install downloads what it needs again, only slower and with the network. They are separate from the node_modules folder inside each project, which is what your app actually runs on.
Where each cache is
| Tool | Mac | Ubuntu | Ask the tool |
|---|---|---|---|
| npm | ~/.npm (_cacache, _npx) |
~/.npm |
npm config get cache |
| Yarn 1 | ~/Library/Caches/Yarn |
~/.cache/yarn |
yarn cache dir |
| Yarn 2+ (Berry) | ~/.yarn/berry/cache |
~/.yarn/berry/cache |
yarn config get cacheFolder |
| pnpm | ~/Library/pnpm/store |
~/.local/share/pnpm/store |
pnpm store path |
| Bun | ~/.bun/install/cache |
~/.bun/install/cache |
bun pm cache |
Sizes first, so you know what you win:
du -sh ~/.npm ~/.bun/install/cache 2>/dev/null
du -sh "$(pnpm store path)" 2>/dev/null
du -sh "$(yarn cache dir)" 2>/dev/null
npm
npm cache verify # checks the cache and removes garbage
npm cache clean --force # deletes everything
npm cache clean refuses without --force because npm repairs its own cache; deleting it is harmless. The _npx folder inside holds packages that npx ran once; it goes with the rest.
Yarn
yarn cache dir
yarn cache clean # Yarn 1: everything (or: yarn cache clean <package>)
yarn cache clean --all # Yarn 2+: the global cache and the project's
A Yarn 2+ project can store its packages inside the repository, in .yarn/cache (Plug’n’Play and zero-installs). Do not delete that folder if it is committed to Git: the project would not run until yarn install fetches everything again. Only the global ~/.yarn/berry/cache is a plain download cache.
pnpm
pnpm store path
pnpm store prune # removes packages no project uses any more
pnpm links files from its store into each project’s node_modules (hard links, or clones on macOS). Two things follow:
pnpm store pruneis the safe command: it removes only what no project references.- Deleting the whole store by hand frees less than its size while those projects exist, because their
node_modulesstill hold the files. The space comes back when you delete the oldnode_modulestoo.
Bun
bun pm cache # prints the folder
bun pm cache rm # deletes it
Bun clones files from its cache into node_modules on a Mac (hard links on Linux), so as with pnpm the cache frees less than its size while projects still use those files.
The same cache, one level up
Version managers keep their own downloads: nvm stores installers in ~/.nvm/.cache and every Node version in ~/.nvm/versions. See old runtime versions for those, and stale node_modules and build folders for the bigger prize: the node_modules of projects you no longer touch. For the caches of other ecosystems, see Python caches and Rust, Go and Java package caches.
How CleanMate does it
CleanMate lists these under Smart Scan › Developer Junk, each tool its own item with its size, on a Mac (macOS features) and on Ubuntu (Ubuntu features). Nothing is removed until you confirm.
- npm, Yarn, pnpm and Bun caches: each is its own item. On a Mac, npx’s cache is separate and is skipped while
npxruns, and the Yarn and Bun caches are skipped while that tool runs. - pnpm: the item is the part of the store no project uses, as
pnpm store pruneremoves it. pnpm cannot preview a prune, so on a Mac its size is shown as “Up to …”: the real freed space can be smaller. - Bun: on a Mac its size is also shown as “Up to …”, because of the clones above.
- Yarn Berry’s global cache (
~/.yarn/berry/cache) is a separate item on a Mac, not ticked, because Plug’n’Play projects needyarn installagain. - If you moved a cache with
.npmrcor a similar setting, CleanMate asks the installed tool where it is now.
What CleanMate does not do: it never touches a project’s .yarn/cache, and it does not remove a project’s node_modules unless the project has been idle for 90 days; those are separate items, not ticked, and go to the Trash so a fresh install can bring them back.
FAQ
Is it safe to run npm cache clean --force? Yes. It deletes downloaded tarballs and metadata. The next npm install downloads them again; your projects and global packages stay.
Will clearing the pnpm store break my projects? No. Their node_modules keep working, because the files are linked there too. A later install of a package that is no longer in the store downloads it again.
Why did the cache come back at the same size? Every install refills it. The cache is a copy kept for speed: clear it when you need the space, not as a habit.
Should I clear the cache in CI? Usually not: a restored cache is what makes CI fast. Clear it locally, or change the cache key when a bad entry needs to go.

