EINTEGRITY

npm ERR! code EINTEGRITY: Fix for package install failures

Getting npm ERR! code EINTEGRITY when installing packages? The cached integrity hash doesn't match. Clear npm cache and retry. Works 90% of the time.

What triggers the npm ERR! code EINTEGRITY error?

This error hits you right when you run npm install — often in the middle of downloading a package. You'll see something like:

npm ERR! code EINTEGRITY
npm ERR! sha512-... integrity check failed for some-package (expected "sha512-..." got "sha512-...")

I've seen it most often when someone's Internet connection drops mid-download, or when a corporate proxy or VPN rewrites traffic. Another trigger: switching between npm registries (e.g., from a private registry to the public one) without clearing cache. Also happens if you've got an old cached version that conflicts with the current package hash.

What's really going on?

npm verifies every package you download using a SHA-512 hash stored in the registry. When you install a package, npm checks the hash it gets from the registry against the hash of the file it just downloaded. If they don't match, you get EINTEGRITY.

Usually the cache is the culprit. npm keeps a local copy of downloaded packages in ~/.npm/_cacache. If that cached copy got corrupted — maybe a partial download, or a disk write error — npm sees the bad file and compares it to the registry's hash. Mismatch. Boom.

The fix: clear cache and retry

  1. Clear npm's cache
    Run this in your terminal:
    npm cache clean --force
    You'll see no output if it works. That's normal. After running it, the cache folder is wiped clean.
  2. Delete node_modules and package-lock.json
    This removes any potentially corrupted local packages and lock file:
    rm -rf node_modules package-lock.json
    On Windows, use:
    rmdir /s node_modules && del package-lock.json
  3. Run npm install again
    npm install
    npm will re-download everything fresh. It'll take a bit longer this time because cache is empty, but the integrity mismatch should be gone.

After step 3, you should see packages installing normally — no EINTEGRITY error. If you still get it, move to the next section.

Still failing? Check these things

1. Your registry URL

If you're using a custom registry (like a private npm registry or Verdaccio), make sure it's still reachable and the packages are published correctly. Run:

npm config get registry

If it's set to something other than https://registry.npmjs.org/, check that the custom registry has the packages you need. Sometimes the registry URL has a trailing slash missing — that'll cause mismatches. Set it to the default public registry to test:

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

2. Network or proxy interference

Corporate proxies, VPNs, or antivirus software sometimes modify HTTPS traffic. That changes the file content, and the hash check fails. Try running npm install with a different network — like using your phone's hotspot. If it works on another network, you've got a proxy issue. You can also set the npm proxy config:

npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080

3. Disk space

npm writes cache files to your system. If your drive is full, writes can be incomplete. Check free space. On Linux/Mac: df -h. On Windows: check This PC.

4. Node or npm version

Older versions of npm (pre-5.x) handled integrity checks differently. Update to the latest stable npm:

npm install -g npm@latest

Then retry the install.

One last thing

If nothing else works, try manually removing the specific cached package. The error message tells you which package failed — for example, some-package. You can delete just that package's cached file:

npm cache clean --force

Wait, that's the same as before. I know. But sometimes you need to do it twice. I've seen cases where the first clean doesn't clear a locked file. Run it again, then delete node_modules and retry.

That's it. This fix has gotten me through hundreds of npm installs. It'll work for you too.

Related Errors in Programming & Dev Tools
java.lang.OutOfMemoryError: Java heap space Fix Java OutOfMemoryError: Java heap space Uncaught TypeError: Cannot read properties of undefined (reading 'map') React map() fails on undefined array props Permission denied (publickey) Fix GitHub SSH 'Permission denied (publickey)' after key rotation 0X800F0239 SPAPI_E_UNKNOWN_EXCEPTION (0x800F0239) fix for driver installs

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.