If you have been using Yarn for a while on macOS, its global cache can quietly grow to several gigabytes without you realizing it. Knowing how to clear yarn cache properly — and safely — requires understanding which version of Yarn you are running, where it stores its files, and what the difference is between the built-in command and a manual deletion.
Yarn Classic vs Yarn Berry: Different Caches, Different Paths
Yarn has two very different major versions in widespread use, and they cache files in separate locations. Before you run any cleanup command, confirm which version you are using:
yarn --version
- 1.x — Yarn Classic
- 2.x, 3.x, 4.x — Yarn Berry
The cache behavior and commands differ enough that conflating them causes confusion. The sections below cover each separately.
Yarn Classic Cache (v1.x)
Where is the Yarn Classic cache on macOS?
Yarn Classic stores its global package cache inside the macOS user Caches directory. To find the exact path on your machine:
yarn cache dir
The default output is typically:
/Users/yourname/Library/Caches/Yarn/v6
You can open it directly in Finder:
open "$(yarn cache dir)"
How to check the Yarn cache size
Before wiping anything, it is worth knowing how much space you are actually dealing with:
du -sh "$(yarn cache dir)"
On an active development machine this directory commonly reaches 2–8 GB depending on how many projects and how many package versions have been installed over time.
How to clear Yarn Classic cache
The recommended way is the built-in command:
yarn cache clean
This removes all cached packages from the global cache directory. Yarn will re-download packages from the registry the next time you run yarn install in any project. Your node_modules folders and yarn.lock files are not touched — only the global download cache is deleted.
You can also remove the cache for a single package if you want to force a fresh download of just one dependency:
yarn cache clean <package-name>
Manual deletion (when the command fails)
If Yarn itself is broken or you prefer a direct approach:
- Find the cache directory:
yarn cache dir - Delete it:
rm -rf "$(yarn cache dir)" - Yarn will recreate the directory structure on the next install.
This is safe because the Yarn Classic cache is purely a download cache — nothing in it is the authoritative copy of your code or configuration.
Yarn Berry Cache (v2, v3, v4)
Where is the Yarn Berry cache on macOS?
Yarn Berry stores its global cache in a different location by default:
yarn cache dir
On macOS this typically resolves to:
/Users/yourname/Library/Caches/Yarn/Berry
However, Yarn Berry is highly configurable. If your project or global .yarnrc.yml overrides globalFolder, the cache location changes. Always run yarn cache dir to confirm.
Yarn Berry also supports Plug'n'Play (PnP)
If your project uses Plug'n'Play mode (the default in newer Berry projects), packages are not stored in node_modules at all — they live in .yarn/cache inside the project directory as zip archives. This is a per-project cache, not a global one. Deleting it forces Yarn to unpack packages again but does not lose anything permanent, because the zip files are usually committed to the repository (zero-install workflow) or can be re-fetched.
To clear the Berry global cache:
yarn cache clean --all
Comparison: Yarn Classic vs Yarn Berry Cache
| Property | Yarn Classic (v1) | Yarn Berry (v2–4) |
|---|---|---|
| Default cache path | ~/Library/Caches/Yarn/v6 | ~/Library/Caches/Yarn/Berry |
| Clean command | yarn cache clean |
yarn cache clean --all |
| Per-project cache | No | Yes (.yarn/cache in project) |
| PnP mode | No | Yes (optional, often default) |
| Safe to delete? | Yes — regenerable | Yes — regenerable (except zero-install zips you intend to keep committed) |
Is It Actually Safe to Delete the Yarn Cache?
In almost every case, yes. The global Yarn cache is a download cache — Yarn keeps copies of packages there so it does not need to hit the network on every fresh install. Deleting it has two consequences:
- Your next
yarn installin any project will be slower because packages must be re-downloaded. - Nothing else breaks. Your code, lock files, and
node_modulesdirectories are unaffected.
If you are not certain what a particular directory under ~/Library/Caches is — or whether something inside it is safe to remove — Crumb's built-in AI can help. Select any folder in Crumb's Visualize view and ask "Is this safe to delete?" Crumb explains what the folder is for and whether its contents are regenerable, so you can make an informed decision before wiping anything. It is especially useful when you encounter unfamiliar cache directories from tools like Yarn, pnpm, Bun, or CocoaPods sitting side by side.
Cleaning node_modules Is a Separate Step
Clearing the Yarn cache does not remove node_modules from your projects. If you want to free space from project dependencies too, you need to do that separately — either manually or with a tool like npx npkill to scan for and remove abandoned node_modules folders across your filesystem.
A quick one-liner to see your largest node_modules directories:
find ~ -name "node_modules" -type d -prune -print | xargs du -sh 2>/dev/null | sort -hr | head -20
This gives you a ranked list of the biggest offenders so you know where to focus.
How Much Space Can You Reclaim?
This varies entirely by how long you have been using Yarn and how many projects you maintain. The Yarn cache deduplicates package versions across projects — a package at a given version is only stored once globally — so the savings from clearing it represent cached downloads, not unique data you cannot get back.
Common space recovered from the global Yarn cache alone:
- Light use (a few projects): 200 MB–1 GB
- Active developer (many projects, years of use): 3–10 GB
- Monorepo with many lockfile resolutions over time: can exceed 10 GB
If you want a visual breakdown of exactly what is eating your disk — not just Yarn but everything — download Crumb and use its disk map to see the full picture at a glance, then drill into caches and development directories to decide what to clear.
Quick Reference: Commands to Clear Yarn Cache on macOS
- Check your Yarn version:
yarn --version - Find the cache location:
yarn cache dir - Check the size:
du -sh "$(yarn cache dir)" - Clear it (Classic):
yarn cache clean - Clear it (Berry):
yarn cache clean --all - Verify it is gone:
du -sh "$(yarn cache dir)"
Clearing the Yarn cache is one of the lower-risk disk cleanup tasks on a developer Mac — the data is transient by design and Yarn regenerates it automatically. The main cost is a slower first install afterward, which is usually a worthwhile trade for recovering several gigabytes of space.