DevCleaner
Menu
Skip to content
Browse guides

How to clear yarn cache (yarn cache clean)

Yarn classic and Yarn Berry keep the cache in different folders, and they do not share one clean command. Check the version before you delete anything.

On this page

Which Yarn you have

yarn --version

Yarn 1 is classic. Yarn 2 and later are Berry. The cache is a download cache SAFE. Packages come back from the registry on the next install. It is not node_modules.

yarn cache clean

YarnUsual cacheTypical sizeCommand
Classic~/Library/Caches/Yarn1 to 8 GByarn cache clean
Berry~/.yarn/berry/cache1 to 6 GByarn cache clean --all

Measure the folder you actually have:

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

Custom settings can move these paths. The sizes are the ranges already used on the combined cache guide, not a measured saving on your Mac.

Not node_modules

Clearing the Yarn cache does not remove project node_modules folders. If those are the gigabytes you are looking at, read can I delete node_modules?

The other package managers: how to clear npm cache and how to clear pnpm cache. All three commands sit together on npm, yarn, and pnpm cache.

FAQ

How do I clear the Yarn cache on Mac?
For Yarn classic, run yarn cache clean. The cache is usually ~/Library/Caches/Yarn. For Yarn Berry, run yarn cache clean --all. The Berry cache is usually ~/.yarn/berry/cache. Check yarn --version first.
Does yarn cache clean delete node_modules?
No. yarn cache clean clears the download cache. It does not remove a project's node_modules folder. Packages download again on the next install.

Scan it with DevCleaner

DevCleaner shows the Yarn cache next to npm, pnpm, and other developer tools before you delete it. Safe cleanup is free.

Download DevCleaner ↓

References and scope

Commands and paths are the ones already published in the combined npm, Yarn, and pnpm guide. Yarn version and configuration can change the folder. Size ranges are illustrative, not a recovery guarantee. Run yarn --version and the matching clean command for that version.