I am getting this error while running sudo npm install
. On my server, npm was installed earlier. I\'ve tried to delete the package-lock.json
file,
all solutions failed for me till i checked router settings; it was set to only IPV4.. i changed and put ipv4v6 and all is working fine now.
Updating .npmrc
and the registry to https://
worked for me
registry=https://registry.npmjs.org/
You should check Connection-specific DNS Suffix when type “ipconfig” or “ifconfig” in terminal
Before i was running this command
npm install typescript -g
after changing the command it worked perfectly.
npm install -g typescript
Delete package-lock.json file and then try to install
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:
So there really is some integrity checksum in the package-lock.json
to verify that the file you are downloading hasn't been tampered with. It's just that somehow the integrity checksum was replaced in our package-lock.json
with a SHA1 instead of a SHA-512 checksum. I have no idea how this happened.
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 by the first two checksums in package-lock.json
:
sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==
and put the third checksum into its "integrity" field:
sha512-WXI95kpJrxw4Nnx8vVI90PuUhrQjnNgghBl5tn54rUNKZYbxv+4ACxUzPVpJEtWxKmeDwnQrzjc0C2bYmRJVKg==
A more detailed description is here.