~/Library/Caches/Yarn is the global cache where Yarn Classic keeps downloaded package archives so repeat installs are fast. It is safe to clear. Run yarn cache clean and the cache refills the next time you run yarn install. Your projects and node_modules folders are not touched.
- Path
~/Library/Caches/Yarn- What it is
- Yarn Classic's global cache of downloaded package archives
- Typical size
- Several hundred megabytes to many gigabytes, depending on how many projects you install
- Made by
- Yarn (Classic 1.x)
- Safe to delete?
- Safe to clear
- Comes back?
- Yes, the cache refills as you run yarn install
What is in this folder?
Yarn Classic downloads each package once into a versioned folder here and copies it into your project. Yarn's documentation says yarn cache clean clears the global cache, which is repopulated the next time you run yarn or yarn install.
Newer Yarn versions (Berry, 2 and later) work differently. They store packages in a .yarn/cache folder inside a project when zero-installs are on, or in a global folder under ~/.yarn/berry. Those project caches may be committed to Git, so check before deleting them.
Is it safe to delete?
Yes for the global cache folder. Everything in it is a copy of a registry download. If you have a project using zero-installs with .yarn/cache committed, that folder is part of your repository, so do not delete it without checking.
How do I clear it by hand?
- Stop any running install.
- Check where the cache is, then clear it.
- Run
yarn installin a project when you need packages again.
yarn cache dir
yarn cache cleanYou can name a package, as in yarn cache clean <package>, to remove just that one.
How do I stop it growing?
Run yarn cache clean occasionally. Yarn does not cap the global cache on its own.
How Clean House handles it
Clean House recognizes the Yarn cache as downloaded JavaScript packages made by Yarn and marks it as something that comes back. It leaves the folder alone while Yarn is running, and everything it clears goes to the Trash first.