When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)

The issue was indeed in package-lock.json, and after replacing it with a working version from another branch it worked.

What's interesting is seeing the diff:

diff

So there really is some integrity checksum in the package-lock.json and it was replaced in our package-lock.json with a SHA1 instead of a SHA-512 checksum. See here for more info.

In case you don't have a working version in another branch. Consider the message

npm ERR! code EINTEGRITY
npm ERR!
  sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==
integrity checksum failed when using sha512: wanted
  sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==
but got
  sha512-WXI95kpJrxw4Nnx8vVI90PuUhrQjnNgghBl5tn54rUNKZYbxv+4ACxUzPVpJEtWxKmeDwnQrzjc0C2bYmRJVKg==
. (65117 bytes)

Find the package in package-lock.json using the first checksum:

sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==

and put the third checksum into its "integrity" field:

sha512-WXI95kpJrxw4Nnx8vVI90PuUhrQjnNgghBl5tn54rUNKZYbxv+4ACxUzPVpJEtWxKmeDwnQrzjc0C2bYmRJVKg==

A more detailed description is here.


See https://github.com/npm/npm/issues/16861

This worked for me:
npm cache verify

Then I re-ran:
npm install -g create-react-app

And it installed as expected: Issue resolved.


Other solutions mentioned in the GitHub issue include:

npm cache clean --force

OR

Deleting npm and npm-cache folders in Users%username%\AppData\Roaming (Windows 7 and Windows 10) and running npm install

OR

Update npm by via npm i -g npm

OR

Delete package-lock.json

OR

npm cache clean

OR

Do these steps to fix the problem:

  1. Find all outdated packages and update theme:
    npm outdated -g
    sudo npm i -g outDatedPKG
  2. Upgrade npm to latest version with:
    sudo npm i -g npm
  3. Delete package-lock.json file.
  4. Delete _cacache directory in ~/.npm: npm cache verify
  5. Every time I get that error, do steps 2 & 3.
  6. If you still get the error, clear npm's cache:
    npm cache clean --force

OR

  1. Add proxy to .npmrc in ~ directory:

proxy=http://localhost:8123
https-proxy=http://localhost:8123

  1. Try again! slow internet connection and censorship may cause this ugly problem.

OR

npm cache clear --force && npm install --no-shrinkwrap --update-binary

OR

npm config set package-lock false


Delete package-lock.json file and then try to install