How to fix npm ERR! code EINTEGRITY npm ERR! cacache integrity error in npm

npmINTERMEDIATEHIGHUpdated Dec 5, 2025· 161 views

The EINTEGRITY cacache error occurs when npm's content-addressable cache detects that a downloaded package's checksum doesn't match the expected hash. This typically results from corrupted cache, hash algorithm mismatches, or network interruptions.

Quick fix

Fixes npm ERR! code EINTEGRITY npm ERR! cacache integrity error

npm cache verify
  1. Verify and repair your npm cache
  2. Force clean the npm cache
  3. Delete lock file and node_modules, then reinstall
  4. Update npm to the latest version
npm — error
npm cache verify
npm ERR! code EINTEGRITY
npm ERR! cacache integrity error

What this error means

The EINTEGRITY error is npm's way of protecting you from installing tampered or corrupted packages. npm uses the cacache library—a content-addressable cache that stores all downloaded packages with cryptographic checksums (typically SHA-512). When npm retrieves a package, it recalculates the hash and compares it to the expected value. If they don't match, npm rejects installation to prevent deploying potentially compromised code. The error specifically indicates a mismatch between: 1. The hash of the downloaded tarball 2. The hash in your local package-lock.json file 3. The hash from the npm registry This validation happens automatically in npm v5+, which made the cache self-healing but also more strict about integrity.

Typical symptoms

  • npm install fails with 'npm ERR! code EINTEGRITY' message
  • Error message shows 'integrity checksum failed' or 'tarball data seems to be corrupted'
  • npm install works for some packages but fails on others
  • Builds fail in CI/CD pipelines at the npm install step
  • Error appears after updating Node.js or npm version

Common causes

  1. Corrupted npm cache from incomplete downloads or interrupted installations
  2. Hash algorithm mismatch (older npm uses SHA-1, newer uses SHA-512)
  3. System clock is out of sync, affecting certificate validation
  4. Network interruptions during package downloads
  5. npm or Node.js version changes between team members or environments
  6. Corporate proxy or network filtering modifying package downloads
  7. Manual edits to package-lock.json with incorrect hash values

How to fix "npm ERR! code EINTEGRITY npm ERR! cacache integrity error"

1Verify and repair your npm cache

Run npm's built-in cache verification command:

bash
npm cache verify

This scans your cache for corrupted entries and removes them without clearing everything. After running this, try npm install again.

2Force clean the npm cache

If cache verification didn't solve the problem, completely remove all cached data:

bash
npm cache clean --force
npm install

This removes your entire cache (~/.npm/_cacache), so npm will need to re-fetch all packages.

3Delete lock file and node_modules, then reinstall

Perform a complete clean reinstall:

bash
rm -rf package-lock.json node_modules
npm cache clean --force
npm install

This regenerates package-lock.json from scratch with fresh integrity hashes.

4Update npm to the latest version

Version mismatches can cause integrity errors:

bash
npm install -g npm@latest
npm install

This is especially important if package-lock.json was created with a newer npm (SHA-512) but your local npm is older (SHA-1).

5Check and fix your system clock

EINTEGRITY errors can be triggered by an out-of-sync system clock:

On Linux:

bash
sudo ntpdate -s time.nist.gov

On macOS/Windows:
Enable automatic date/time in system settings.

6Verify npm registry configuration

Ensure you're using a reliable npm registry:

bash
npm config get registry

If it's not the official registry, switch to it:

bash
npm config set registry https://registry.npmjs.org/

Advanced notes

Understanding cacache: npm's local cache (~/.npm/_cacache) uses content-addressing, where packages are stored by their hash. This allows npm to detect corruption—if a file's stored hash doesn't match its content, npm knows it's corrupt.

SHA-1 vs SHA-512: npm v5+ uses SHA-512 by default, but older versions used SHA-1. This causes mismatches when teams mix npm versions. The package-lock.json file stores these integrity strings.

Self-healing cache: The cache should never need clearing for security reasons—npm's design automatically refetches corrupted data. Persistent EINTEGRITY errors may indicate deeper issues: system time skew, ISP packet loss, or corporate proxies modifying traffic.

CI/CD: Ensure all agents use identical Node and npm versions to avoid lock file regeneration.

Frequently asked questions

What does "npm ERR! code EINTEGRITY npm ERR! cacache integrity error" mean?
The EINTEGRITY error is npm's way of protecting you from installing tampered or corrupted packages. npm uses the cacache library—a content-addressable cache that stores all downloaded packages with cryptographic checksums (typically SHA-512). When npm retrieves a package, it recalculates the hash and compares it to the expected value.
How do I fix "npm ERR! code EINTEGRITY npm ERR! cacache integrity error"?
The EINTEGRITY cacache error occurs when npm's content-addressable cache detects that a downloaded package's checksum doesn't match the expected hash. This typically results from corrupted cache, hash algorithm mismatches, or network interruptions.
What causes "npm ERR! code EINTEGRITY npm ERR! cacache integrity error"?
Corrupted npm cache from incomplete downloads or interrupted installations Hash algorithm mismatch (older npm uses SHA-1, newer uses SHA-512) System clock is out of sync, affecting certificate validation
Is the "npm ERR! code EINTEGRITY npm ERR! cacache integrity error" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading