Guide

Yarn cache clean on Mac, for every Yarn.

Yarn 1 and Yarn 2 and later keep their caches in different places and clear them with different flags. Start by finding out which one a project uses.

The short version

For Yarn 1 (classic), run yarn cache clean; its cache is ~/Library/Caches/Yarn on a Mac. For Yarn 2 and later (Berry), run yarn cache clean --all inside a project to clear both the shared cache in ~/.yarn/berry/cache and that project's cache. If a project commits .yarn/cache to git, leave that folder alone.

Yarn cache location on Mac

First, check which Yarn a project runs. Inside the project folder:

yarn --version

1.x is classic Yarn. 2.x, 3.x, or 4.x is Berry, usually pinned by the packageManager field in package.json, so one Mac can run both. Each keeps its cache in a different place:

WhatDefault locationOn one Mac
Yarn 1 cache~/Library/Caches/Yarn/v6424 MB
Yarn Berry shared cache~/.yarn/berry/cacheNot present on the Mac we measured
Yarn Berry project cacheyour-project/.yarn/cachePer project

Sizes are from one developer Mac in October 2026, which only had classic Yarn caches. To print the location yourself, use yarn cache dir for Yarn 1, or yarn config get cacheFolder inside a Berry project. Yarn 4 uses the shared cache by default; Yarn 2 and 3 keep a cache per project unless enableGlobalCache is on.

How to clear Yarn cache

Yarn 1 (classic)

yarn cache list               # what's cached
yarn cache clean              # everything
yarn cache clean lodash       # one package

Yarn 2 and later (Berry)

yarn cache clean              # this project's cache
yarn cache clean --mirror     # the shared cache in ~/.yarn/berry/cache
yarn cache clean --all        # both

Run Berry's commands from inside a Berry project, since that's where Yarn decides which version to use. In Yarn 4, plain yarn cache clean may have little to clear because packages go to the shared cache; --all is the one that reclaims space.

Is it safe to clear Yarn cache?

Yes, with one exception. The cache only holds package archives, and the next yarn install fetches what's missing. Your lockfile decides what gets installed, so nothing changes about your dependencies.

The exception: zero-installs. Some Berry projects commit .yarn/cache to git so a fresh clone runs without an install. In those, the folder is part of the repository. Deleting it shows up as hundreds of changed files. Check git status before you touch it.

How big the Yarn cache gets

Like npm, Yarn keeps every version you've downloaded. Classic Yarn also keeps unpacked copies, so it grows faster than you'd expect. On the developer Mac above, it was 424 MB, which is small because most projects there use npm and pnpm. On a Mac that's used Yarn for years, a few gigabytes is common.

What about node_modules?

Projects using classic Yarn, or Berry with nodeLinker: node-modules, have a node_modules folder in each project, and those usually add up to more than the cache. Delete them in old projects; yarn install brings them back. Berry's default Plug'n'Play mode has no node_modules at all: it reads packages straight from the cache, which is why the cache matters more there.

Also clearing npm? See npm cache clean. Or browse every tool's cache.

Disk Forecast finds this for you

Classic Yarn's cache is in ~/Library/Caches, so Disk Forecast lists it as the Yarn entry under Cleanup › Safe to clear › App caches. Berry's shared cache in ~/.yarn/berry/cache isn't listed; clear it with yarn cache clean --mirror. node_modules folders next to a package.json show up under Build folders in old projects or Build folders in active projects, depending on when you last changed the project. Everything goes to the Trash. It's free.

Questions

How do I clear the Yarn cache?

For Yarn 1, run yarn cache clean. For Yarn 2 and later, run yarn cache clean --all inside a project to clear the shared cache and that project's cache. Check which you have with yarn --version.

Where is the Yarn cache located on a Mac?

Yarn 1 uses ~/Library/Caches/Yarn; run yarn cache dir to confirm. Yarn 2 and later use ~/.yarn/berry/cache for the shared cache and .yarn/cache inside each project.

What's the difference between yarn cache clean and yarn cache clean --all?

In Yarn 2 and later, yarn cache clean removes the current project's cache, --mirror removes the shared cache, and --all removes both. In Yarn 1, yarn cache clean removes the whole cache.

Is it safe to delete the Yarn cache?

Yes, unless the project commits .yarn/cache to git for zero-installs. Then the folder is part of the repository. Otherwise, yarn install downloads what's missing.

Know before it's full.

Free. No account, no subscription.

macOS 14 or later · Apple Silicon and Intel · brew install --cask coreyhaines31/tap/diskforecast