Skip to content
Latchkey

yarn cache clean: Usage & Common Errors

Clear the Yarn package cache.

yarn cache clean empties the Yarn package cache - the fix for a corrupted cached tarball or a checksum mismatch that survives reinstalls.

What it does

Removes cached packages from the global cache directory (yarn cache dir shows where). In Berry the cache is project-local (.yarn/cache) by default, so yarn cache clean clears that store. After cleaning, the next install re-fetches from the registry.

Common usage

Terminal
yarn cache clean            # clear the cache
yarn cache dir              # Yarn 1: print cache location
yarn cache clean --all      # Berry: clear the whole cache

Common CI error: checksum mismatch survives reinstall

CI keeps failing with "integrity check failed" / "computed checksum did not match" even after reinstalling, because a corrupt tarball is cached. Clean the cache then reinstall - and key any CI cache on the lockfile hash so a poisoned cache is not restored next run.

Terminal
yarn cache clean && yarn install --check-cache

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →