misonoteApp Center

Yarn cache on Mac: safe to delete? How to clear it

Safe to deleteRegenerated automatically; Thermo deletes it outright.

Where it is

  • ~/Library/Caches/Yarn
  • ~/.yarn/berry/cache

What it is

Yarn keeps a global cache of every package it downloads so repeat installs are fast. Yarn Classic (v1) stores unpacked packages in ~/Library/Caches/Yarn, while Yarn 2 and later (Berry) keep zip archives in a global cache under ~/.yarn/berry.

Why it gets so big

Yarn keeps every version you've ever installed, and Yarn Classic stores packages unpacked, which means far more space and many more files than compressed archives would take.

Is it safe to delete?

Yes. Clearing it only means the next install downloads packages again. One caveat for Yarn Berry: Plug'n'Play projects that use the global cache read packages straight from these zip files, so run yarn install in those projects afterwards. Projects that commit their own .yarn/cache folder (zero-installs) are unaffected.

See how much space it uses

du -sh "$HOME/Library/Caches/Yarn" "$HOME/.yarn/berry/cache" 2>/dev/null

Clean it with the tool’s own command

yarn cache clean

Delete it by hand

Run in Terminal. Deleting cannot be undone, so check the paths first.

rm -rf "$HOME/Library/Caches/Yarn"/*
rm -rf "$HOME/.yarn/berry/cache"/*