Fix a npm install failure with error code EINTEGRITY
Asked Answered
W

7

18

I have browsed through various similar posts here to no avail. They all arrive at similar solutions about using npm cache verify or npm cache clear, etc.

I have even went as far as to completely remove npm and node using every possible method and start fresh. I even resorted to using --force. Nothing has worked. I am sharing the latest log in hopes someone can point out my oversite or at least direct me to a possible solution.

I am sharing the latest log below.

========================================================================

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'i',
1 verbose cli   'npm',
1 verbose cli   '-g',
1 verbose cli   '--force' ]
2 info using [email protected]
3 info using [email protected]
4 warn using --force I sure hope you know what you are doing.
5 verbose npm-session 9e6a63471e97c268
6 silly install loadCurrentTree
7 silly install readGlobalPackageData
8 http fetch GET 200 https://registry.npmjs.org/npm 151ms
9 silly pacote tag manifest for npm@latest fetched in 302ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 silly install loadShrinkwrap
13 silly install loadAllDepsIntoIdealTree
14 silly resolveWithNewModule [email protected] checking installable status
15 silly pacote trying https://registry.npmjs.org/npm/-/npm-5.7.1.tgz by hash: sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA==
16 silly pacote data for sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA== not present. Using manifest.
17 verbose stack Error: sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA== integrity checksum failed when using sha512: wanted sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA== but got sha512-iBtbJV6DQB9dnO+DHun+8z2zKH2zz8pd5nJQL1NNwCxzeYJnSKIa/pmkgRHxYDIhEkRUKbm8wVdQuwxnaL5jhg==. (2162194 bytes)
17 verbose stack     at Transform.on (/usr/local/lib/node_modules/npm/node_modules/ssri/index.js:275:19)
17 verbose stack     at emitNone (events.js:111:20)
17 verbose stack     at Transform.emit (events.js:208:7)
17 verbose stack     at endReadableNT (_stream_readable.js:1055:12)
17 verbose stack     at _combinedTickCallback (internal/process/next_tick.js:138:11)
17 verbose stack     at process._tickCallback (internal/process/next_tick.js:180:9)
18 verbose cwd /Users/jasongribble
19 verbose Darwin 16.7.0
20 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "npm" "-g" "--force"
21 verbose node v8.9.4
22 verbose npm  v5.6.0
23 error code EINTEGRITY
24 error sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA== integrity checksum failed when using sha512: wanted sha512-r1grvv6mcEt+nlMzMWPc5n/z5q8NNuBWj0TGFp1PBSFCl6ubnAoUGBsucYsnZYT7MOJn0ha1ptEjmdBoAdJ+SA== but got sha512-iBtbJV6DQB9dnO+DHun+8z2zKH2zz8pd5nJQL1NNwCxzeYJnSKIa/pmkgRHxYDIhEkRUKbm8wVdQuwxnaL5jhg==. (2162194 bytes)
25 verbose exit [ 1, true ]
Wismar answered 4/3, 2018 at 6:40 Comment(4)
"I have even went as far as to completely remove npm and node" -> You mean you tried to remove the "node_modules" folder in your project?Subtile
I should have been specific. Not only a project but globally. Even searched for all node modules and npm folders. I wanted it wiped from the entire system. This EINTEGRITY error has been baffled.Wismar
Did it work some days ago on the same computer and suddenly something messed it up or you installed NodeJS with npm and from the beginning it did not work?Subtile
I was getting the same eror. but "npm cache verify" worked in my case.Gomes
P
21

Running these commands solved my problem:

rm -rf package-lock.json node_modules
npm install

Reference

Possible answered 11/3, 2020 at 10:56 Comment(0)
V
16

I just experienced this issue as well at work. The cause was that the package-lock.json file in our master branch was outdated, containing old integrity values. By deleting the package-lock.json file, I was able to run npm install and had no more EINTEGRITY errors.

I found the answer to this problem in another SO post: Integrity checksum failure while installing API Connect toolkit #apiconnect.

They came up with the answer via this GitHub issue comment for npm: https://github.com/npm/npm/issues/16861#issuecomment-305527498

Villada answered 6/7, 2018 at 0:45 Comment(0)
M
7

If this error occurs during the project creation in react-native, then run:

npm cache clean --force

Michey answered 2/3, 2020 at 11:3 Comment(0)
C
1

I deleted node_modules, the package-lock.json in the solution folder, then I re ran npm install, it perfectly worked for me.

Charlot answered 3/3, 2020 at 22:23 Comment(0)
H
0

I see a lot of people suggesting to remove package-lock.json file but I think deleting it is not a very good solution, especially if you are working on code that was written a long time back, it has very specific versions of dependencies, without which code might not run properly.

A better solution, if possible, is to replace the old package-lock.json with one from another working branch or a previous working commit, and then run npm install.

That seemed to have solved the issue for me.

Hanson answered 25/6, 2022 at 6:55 Comment(0)
N
0

Check about the npm registry you used local and remote.

My problem was that I changed the CI registry and committed a local generated package-lock.json which has a different registry.
The different registry is surely has the different signature of the package which caused this issue.

Nobell answered 5/7, 2022 at 17:36 Comment(0)
C
0

For me the problem was that I was building my client-modules-nestjs package with node v 16.12, and then installing it in my project with node v16.14. The fix was to use the very same node version everywhere.

package.json in my-project:

"dependencies": {
    ..
    "@client-modules-nestjs": "file:client-modules-nestjs-1.0.0.tgz",
    ..
}

These are the commands I used, they have to run on the same node version:

.../client-modules-nestjs> npm run build 
.../client-modules-nestjs> npm pack

.../my-project> cp /path/to/client/client-modules-nestjs-1.0.0.tgz .
.../my-project> npm i
Chaucerian answered 29/4 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.