How to fix npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed in npm
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- Verify and clean npm cache
- Full reset with lockfile regeneration
- Update the specific package
- Check for npm version mismatch
# Verify cache integritynpm cache verify# If issues found, force cleannpm cache clean --force# Retry installationnpm installnpm ERR! code EINTEGRITYnpm 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
- Corrupted npm cache files
- Switching between npm versions with different hash algorithms
- Network interruptions causing incomplete downloads
- package-lock.json has outdated integrity hashes
- Switching between different npm registries
- Disk corruption affecting cached packages
How to fix "npm ERR! code EINTEGRITY npm ERR! sha512 integrity checksum failed"
Start with cache verification:
# Verify cache integrity
npm cache verify
# If issues found, force clean
npm cache clean --force
# Retry installation
npm installDelete corrupted files and reinstall:
# 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 installIf error mentions a specific package:
# Remove and reinstall the package
npm uninstall <package-name>
npm install <package-name>
# Or update to latest version
npm update <package-name>Different npm versions use different hash algorithms:
# Check npm version
npm -v
# Update npm to latest
npm install -g npm@latest
# Regenerate lockfile
rm package-lock.json
npm installOnce lockfile is regenerated, use npm ci in CI:
# For reproducible installs
npm cinpm ci is stricter about integrity and fails fast on mismatches.
Verify you're using the correct registry:
# 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 --forceAdvanced 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
- ๐npm Official Documentation
- ๐ฌ
- ๐
- ๐ฌ