SweepBarGet it free

How to clear the Yarn and Bun cache on a Mac

By EgeTech LTD · October 6, 2026 · 2 min read

Yarn and Bun each keep a cache of every package they download. Like the npm cache, it makes repeat installs fast, and like the npm cache it is never needed for your project to run. If you want the space, you can clear it.

Bun

Bun makes it easy. Print the path, then clear it:

bun pm cache
bun pm cache rm

The first command prints the cache folder, by default ~/.bun/install/cache. The second removes it. To see the size before you decide:

du -sh "$(bun pm cache)"

Yarn

Yarn has changed over the years, so check which version you use with yarn --version.

Yarn 1 (Classic). The cache is global. Find it and clear it:

yarn cache dir
yarn cache clean

Yarn 2 and newer (Berry). Depending on your settings, packages are cached either globally in your home folder or inside each project, in a .yarn/cache folder. Clear what Yarn knows about with:

yarn cache clean

Check yarn cache clean --help for the options on your version, such as removing the shared cache as well. If your project commits .yarn/cache to git so that installs work offline (“zero-installs”), that folder is part of your repository. Do not delete it unless you mean to.

When clearing the cache is worth it

When to leave it alone

What it costs

Only time. The next install downloads the packages again. Your projects, your code and your lockfiles are untouched.

The full picture

JavaScript tooling leaves four or five caches on a Mac, not one. Read about the npm cache and why it needs –force and the pnpm store. For all the other folders worth checking, see how to free up disk space on a Mac as a developer.

Quick answers

Is it safe to clear the Yarn or Bun cache?

Yes. Both caches only hold downloaded packages. Clearing them makes the next install slower and needs a network connection, nothing more.

Where is the Bun cache?

Run bun pm cache. By default it is the install/cache folder inside the .bun folder in your home directory.

Does clearing the cache fix a broken install?

Sometimes, if a download was damaged. More often the problem is node_modules or the lockfile, so deleting node_modules and reinstalling is the better first step.