SiftMac
Is it safe to delete? · Package caches · Updated 21 November 2026

Is it safe to delete Yarn’s cache?

By Mohit Nippanikar, who makes SiftMac

The short answer
On this page
  1. Two Yarns, two caches
  2. Where each one lives
  3. How big it gets
  4. How to clear it
  5. What changes afterwards
  6. Questions

1. Two Yarns, two caches

Yarn comes in two lines that store packages differently. Run yarn --version inside a project to see which one it uses: 1.x is Yarn Classic, and anything from 2 up is modern Yarn, often called Berry.

Modern Yarn’s default linker is Plug’n’Play. Instead of a node_modules folder it writes a .pnp.cjs loader that refers to packages by their path in the cache. That makes the cache part of how a project runs, not only a download shortcut.

2. Where each one lives

~/Library/Caches/Yarn      # Yarn Classic
~/.yarn/berry              # Yarn 2+ global folder, cache inside
<project>/.yarn/cache      # Yarn 2+ with the global cache off

Yarn Classic picks ~/Library/Caches/Yarn on a Mac unless XDG_CACHE_HOME, YARN_CACHE_FOLDER or its cache-folder setting says otherwise; yarn cache dir prints the exact folder, version subfolder included. For Yarn 2+, the globalFolder setting decides, and it’s ~/.yarn/berry unless changed.

3. How big it gets

Each cache keeps the packages your projects asked for, version by version, including projects you deleted long ago. A Mac that has used both lines of Yarn can have both folders. Check them together:

du -sh ~/Library/Caches/Yarn ~/.yarn/berry 2>/dev/null
yarn cache dir

4. How to clear it

Use the Yarn that owns the cache:

yarn cache clean            # Yarn 1: the global cache
yarn cache clean --mirror   # Yarn 2+: the global cache

Before clearing a project’s .yarn/cache, run git status there or look in .gitignore. If Git tracks the folder, it’s part of the project rather than a leftover, and deleting it shows up as a long list of deleted files.

5. What changes afterwards

Questions

Which Yarn cache is the big one on my Mac?

Measure both with du -sh ~/Library/Caches/Yarn ~/.yarn/berry. Each version of Yarn only knows and clears its own, so a Mac that has used both may need both commands.

Is it safe to delete .yarn/cache inside a project?

Only if Git doesn’t track it. Teams using Zero-Installs commit that folder so the project runs straight after a checkout; if you delete it and commit, everyone else loses it too.

Will yarn cache clean delete node_modules?

No. It only touches the cache. A project’s node_modules, if it has one, stays until you delete it yourself.

Can I move Yarn’s cache to another disk?

Yes. For Yarn Classic, run yarn config set cache-folder <path> or set YARN_CACHE_FOLDER. For Yarn 2+, set globalFolder in .yarnrc.yml.

How SiftMac handles it. Its App caches category lists ~/Library/Caches/Yarn as Yarn packages with a Rebuilds verdict, ticked by default like other caches, and clears what’s inside while keeping the folder. Modern Yarn’s ~/.yarn folder and projects’ .yarn/cache aren’t cleared by SiftMac; yarn cache clean --mirror handles the global one.

Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works