Skip to content
Latchkey

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

  1. Remove node_modules and clean the yarn cache.
  2. Reinstall so hashes are recomputed from fresh downloads.
Terminal
rm -rf node_modules
yarn cache clean
yarn install

Regenerate the lockfile if it is genuinely stale

  1. Delete yarn.lock and reinstall to rebuild integrity data.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →