How to uninstall Yarn on a Mac, and its two caches
Yarn 1 and Yarn 2 and later cache in different places. On our Mac that was 1.0 GB in Library/Caches/Yarn and 767 MB in ~/.yarn/berry, plus two yarn commands.
How do I uninstall Yarn on a Mac?
- Find every copy:
which -a yarn. Ours had two,/usr/local/bin/yarnand one inside an nvm Node version. - Remove each one:
npm uninstall -g yarnunder each Node version,brew uninstall yarn, orcorepack disable yarn. - Delete both caches:
~/Library/Caches/Yarnand~/.yarn. - Delete
~/.yarnrcand~/.yarnrc.ymlif they exist.
What does Yarn keep on a Mac?
| Where | Size here | What it is |
|---|---|---|
~/Library/Caches/Yarn/v6 | 1.0 GB | Yarn 1's package cache |
~/.yarn/berry/cache | 696 MB | Yarn 2 and later, the global cache |
~/.yarn/berry/metadata | 71 MB | Package metadata |
~/.yarnrc | a few bytes | Settings |
Why does yarn say this project is configured to use pnpm?
That message comes from Corepack, which reads the packageManager field of the nearest package.json. On our Mac, running yarn --version in the home folder printed it, because a stray package.json sat directly in the home folder. Every folder beneath it inherits that setting. If you see it in a folder that is not a project, look for a package.json in a parent folder.
Find what is left in one look
Free Mac shows both Yarn caches and every node_modules on the Storage map and moves what you pick to the Trash. To keep Yarn and only shrink the caches, see Yarn and pnpm stores.
Related: Homebrew lists apps you already deleted and the Chrome Apps folder.
Common questions
Where is the Yarn cache on a Mac?
Yarn 1 uses ~/Library/Caches/Yarn. Yarn 2 and later use ~/.yarn/berry/cache, or a .yarn/cache folder inside each project.
Is it safe to delete the Yarn cache?
Yes. Packages download again the next time a project installs.
Why is yarn still found after npm uninstall -g yarn?
Another copy is on your PATH, under a different Node version, from Homebrew or from Corepack. which -a yarn lists them.