The short answer
- 01
Safe to delete. ~/Library/Caches/Yarn is the global package cache of Yarn 1 (Classic). Projects do not run from it.
- 02
Yarn 1 writes it on every install and keeps every version it ever downloaded.
- 03
You lose download time: the next yarn install fetches packages again.
- 04
The command: yarn cache clean. yarn cache dir prints the exact folder first.
- 05
Yarn 2 and later are different: their shared cache lives under ~/.yarn/berry, and some projects keep a .yarn/cache folder in the repo.
See its real size on your Mac. Hoardless measures this folder and previews the delete.Download free trial
What is the ~/Library/Caches/Yarn folder?
It is the global package cache of Yarn 1, also called Yarn Classic. Yarn's docs say Yarn stores every package in a global cache in your user directory. On a Mac that is usually ~/Library/Caches/Yarn.
yarn cache dir
Prints the folder Yarn 1 uses right now. Removes nothing.
Yarn 2 and later (Berry) do not use this folder. Their settings put a shared cache inside globalFolder, which defaults to ~/.yarn/berry, because enableGlobalCache is on by default.
What writes it and why does it grow?
Every yarn install in a Yarn 1 project writes to it. Yarn keeps each downloaded package version so the next install can reuse it.
- Nothing expires: old versions stay after you upgrade a dependency.
- Shared by every project: all Yarn 1 projects on your Mac add to one cache.
- Leftovers after a switch: moving a project to Yarn 2 or later does not empty the Yarn 1 cache.
How big does the Yarn cache get?
It depends on how many packages and versions you have installed, so there is no normal size. Measure both caches:
du -sh ~/Library/Caches/Yarn
Yarn 1's cache. Removes nothing.
du -sh ~/.yarn/berry
Yarn 2 and later's global folder, including its shared cache. Removes nothing.
yarn cache list
Yarn 1: lists every cached package. Add --pattern to filter.
Is it safe to delete the Yarn cache?
Yarn's docs say the cleared cache is repopulated the next time yarn or yarn install runs.
| What | Verdict | What you lose |
|---|---|---|
~/Library/Caches/Yarn (Yarn 1) | Safe | Cached downloads. The next install fetches them again. |
~/.yarn/berry cache (Yarn 2+) | Safe | The shared cache. Projects download packages again on install. |
A project's .yarn/cache | Careful | If git tracks it, deleting it changes the repo and can break offline installs. |
A project's yarn.lock | Never | The pinned versions. It is source, not cache. |
How do I clear the Yarn cache?
Yarn 1, with Yarn's own command:
yarn cache clean
Clears the global cache. Add one or more package names to clear only those.
Yarn 2 and later, run inside a project: plain yarn cache clean removes the local archives, --mirror the global ones, and --all both.
yarn cache clean --mirror
Removes the global cache shared by your Yarn 2+ projects.
The manual way: quit any running yarn command, then drag ~/Library/Caches/Yarn to the Trash.
What Hoardless does: its Node detector lists ~/Library/Caches/Yarn at the Auto tier and runs yarn cache clean, using the yarn your login shell finds. When yarn is not installed, it moves the folder to the Trash at the same tier, logged in the undo log. Hoardless does not detect the Yarn 2+ cache in ~/.yarn/berry.
What comes back and when?
Only what you install again. The next yarn install in a Yarn 1 project downloads its packages and refills the cache. If no project uses Yarn 1 any more, the folder stays empty.
Clearing the cache does not touch node_modules. To free that space too, see node_modules.
Every JavaScript cache, sized
Hoardless sizes the Yarn 1 cache (Auto tier, yarn cache clean) next to the npm cache and the pnpm store, and previews the plan before anything runs. It does not detect Yarn 2+ or Bun caches.
14-day full trial. macOS 14 or later.
Questions
Does yarn cache clean delete node_modules?
No. It clears Yarn's global cache only. Each project's node_modules stays until you delete it or reinstall.
Can I clean the cache for one package?
Yes, in Yarn 1. yarn cache clean followed by one or more package names clears only those packages.
Why is ~/Library/Caches/Yarn still there after I moved to Yarn 4?
Yarn 2 and later do not use that folder. It is left over from Yarn 1 and can be cleared if no project on your Mac still uses Yarn 1.
Should I delete a project's .yarn/cache folder?
Check first. Some teams commit .yarn/cache to git for offline or zero-install setups. If it is tracked, deleting it changes the repository.
New guides by email
New guides and Hoardless releases, twice a month at most.
Confirm first. Unsubscribe in one click. Privacy.