πŸ”§ Error Fixes
Β· 2 min read
Last updated on

Yarn: Integrity Check Failed β€” How to Fix It


You run yarn install and it blows up with:

error Integrity check failed for "lodash" (computed integrity doesn't match our records)

Or sometimes the more generic variant:

error https://registry.yarnpkg.com/some-package/-/some-package-1.0.0.tgz: Integrity check failed for "some-package"

This means Yarn downloaded a package but the checksum doesn’t match what’s recorded in the lockfile or cache.

What causes this

Yarn stores integrity hashes (SHA-512) for every package it downloads. When it fetches a package β€” either from the registry or its local cache β€” it compares the hash of the downloaded tarball against the expected hash.

A mismatch happens when:

  • The local Yarn cache is corrupted (partial downloads, disk issues, interrupted installs)
  • The lockfile was generated on a different machine with a different registry mirror
  • A registry returned a different tarball for the same version (rare, but happens with private registries)
  • You switched between Yarn versions that use different hash algorithms
  • Network issues caused a partial or corrupted download

Fix 1: Clear the cache and reinstall

This is the nuclear option and it works 95% of the time:

yarn cache clean
rm -rf node_modules
rm yarn.lock
yarn install

If you need to preserve your lockfile (e.g., in a team project), try keeping yarn.lock and only clearing the cache:

yarn cache clean
rm -rf node_modules
yarn install

Fix 2: Clear cache for a specific package

If you know which package is failing, you can target just that one:

yarn cache dir
# Find and delete the cached tarball for the specific package
yarn cache clean some-package
yarn install

This is faster than nuking the entire cache, especially on large projects.

Fix 3: Check your registry configuration

If you’re using a private registry or mirror, the integrity hash might differ from the public npm registry:

# Check current registry
yarn config get registry

# Reset to default
yarn config set registry https://registry.yarnpkg.com

If you’re behind a corporate proxy, the proxy might be modifying responses. Check with your infra team.

Fix 4: Disable integrity checking (temporary)

As a last resort for unblocking yourself, you can skip the check:

yarn install --network-concurrency 1

Reducing concurrency can help if the issue is caused by race conditions during parallel downloads. For Yarn 1, you can also try:

yarn install --check-files

This forces Yarn to verify all files in node_modules and re-download anything that’s off.

How to prevent it

  • Don’t interrupt yarn install mid-run β€” let it finish or it may leave a corrupted cache
  • Commit yarn.lock to version control so all team members use the same resolved versions
  • Use a consistent Yarn version across your team (set it in package.json via engines or use Corepack)
  • If you’re on Yarn 1, consider migrating to Yarn 3+ which uses a more robust caching mechanism with Plug’n’Play
  • Run yarn cache clean periodically in CI environments to avoid stale cache issues
πŸ“˜