How to fix npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed in npm

npmBEGINNERMEDIUMUpdated Dec 6, 2025ยท 288 views

The EINTEGRITY error occurs when a downloaded package doesn't match its expected checksum. Clear npm cache and delete package-lock.json to resolve corrupted integrity hashes.

Quick fix

Fixes npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed

# Verify cache integrity
npm cache verify

# If issues found, force clean
npm cache clean --force

# Retry installation
npm install
  1. Verify and clean npm cache
  2. Full reset with lockfile regeneration
  3. Update the specific package
  4. Check for npm version mismatch
npm โ€” error
# Verify cache integrity
npm cache verify
# If issues found, force clean
npm cache clean --force
# Retry installation
npm install
npm ERR! code EINTEGRITY
npm ERR! sha512 integrity checksum failed

What this error means

The EINTEGRITY error is npm's security feature detecting a mismatch between the expected checksum (stored in package-lock.json) and the actual downloaded package. This prevents installation of potentially corrupted or tampered packages. This typically happens when the npm cache becomes corrupted, when switching between npm versions that use different hash algorithms (SHA1 vs SHA512), or when network issues cause incomplete downloads.

Typical symptoms

  • npm install fails with "integrity checksum failed"
  • Error shows expected vs actual SHA512 hash values
  • Installation works on some machines but fails on others
  • Error persists even with npm install --force
  • Fresh repository clones fail to install dependencies
  • Works after clearing cache but fails again later

Common causes

  1. Corrupted npm cache files
  2. Switching between npm versions with different hash algorithms
  3. Network interruptions causing incomplete downloads
  4. package-lock.json has outdated integrity hashes
  5. Switching between different npm registries
  6. Disk corruption affecting cached packages

How to fix "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed"

1Verify and clean npm cache

Start with cache verification:

bash
# Verify cache integrity
npm cache verify

# If issues found, force clean
npm cache clean --force

# Retry installation
npm install
2Full reset with lockfile regeneration

Delete corrupted files and reinstall:

bash
# Remove node_modules and lockfile
rm -rf node_modules package-lock.json

# Clean npm cache
npm cache clean --force

# Verify cache
npm cache verify

# Reinstall
npm install
3Update the specific package

If error mentions a specific package:

bash
# Remove and reinstall the package
npm uninstall <package-name>
npm install <package-name>

# Or update to latest version
npm update <package-name>
4Check for npm version mismatch

Different npm versions use different hash algorithms:

bash
# Check npm version
npm -v

# Update npm to latest
npm install -g npm@latest

# Regenerate lockfile
rm package-lock.json
npm install
5Use npm ci after fixing

Once lockfile is regenerated, use npm ci in CI:

bash
# For reproducible installs
npm ci

npm ci is stricter about integrity and fails fast on mismatches.

6Check registry configuration

Verify you're using the correct registry:

bash
# Check current registry
npm config get registry

# Reset to default if needed
npm config set registry https://registry.npmjs.org/

# Clear cache after registry change
npm cache clean --force

Advanced notes

The integrity field in package-lock.json uses "algorithm-hash" format (e.g., sha512-xxxxx==). npm v5+ uses SHA512 by default, while older versions used SHA1.

Cache locations:
- Linux/macOS: ~/.npm
- Windows: %AppData%\npm-cache

For CI/CD environments, this error is common when cache is shared across different npm versions. Clear cache at the start of builds or use npm ci which is more strict about integrity verification.

If the error persists after all fixes, the package itself might have been republished with different content (rare but possible). Check the package's npm page for recent updates.

Frequently asked questions

What does "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed" mean?
json) and the actual downloaded package. This prevents installation of potentially corrupted or tampered packages. This typically happens when the npm cache becomes corrupted, when switching between npm versions that use different hash algorithms (SHA1 vs SHA512), or when network issues cause incomplete downloads.
How do I fix "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed"?
The EINTEGRITY error occurs when a downloaded package doesn't match its expected checksum. Clear npm cache and delete package-lock.json to resolve corrupted integrity hashes.
What causes "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed"?
Corrupted npm cache files Switching between npm versions with different hash algorithms Network interruptions causing incomplete downloads
Is the "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading