yarn "Integrity check failed" in CI - Fix Lockfile and Cache Integrity
Yarn records integrity hashes for installed packages. An integrity check failure means the on-disk tree no longer matches the lockfile, from drift or a corrupted cache.
What this error means
yarn install or yarn check fails reporting Integrity check failed, sometimes naming the file lock or package whose hash disagrees. A clean install often succeeds.
yarn
error Integrity check failed
error Found 1 errors.
info Lockfile is out of sync with the integrity file.Common causes
A corrupted or stale yarn cache
Cached artifacts that no longer match the lockfile produce a hash mismatch, which clears on a fresh fetch.
yarn.lock diverged from the installed tree
A partial or hand-edited lockfile encodes hashes that do not match what gets installed.
How to fix it
Clear the cache and reinstall
- Remove node_modules and clean the yarn cache.
- Reinstall so hashes are recomputed from fresh downloads.
Terminal
rm -rf node_modules
yarn cache clean
yarn installRegenerate the lockfile if it is genuinely stale
- Delete yarn.lock and reinstall to rebuild integrity data.
- Commit the refreshed lockfile.
How to prevent it
- Cache the yarn cache keyed on yarn.lock, keep the lockfile in sync, and pin a registry. On Latchkey managed runners a transient corrupted-cache integrity failure is auto-retried against a cached registry, so it usually clears on its own.
Related guides
yarn "Integrity check failed" / checksum mismatch - Fix in CIFix yarn "Integrity check failed for …" / checksum mismatch in CI - a fetched package whose hash does not mat…
npm EINTEGRITY sha512 Mismatch in CI - Fix Tarball Integrity FailuresFix npm EINTEGRITY sha512 checksum mismatches in CI caused by stale lockfile hashes, a corrupted cache, or a…