npm · npm
The message
npm ERR! code EINTEGRITY
What it means
The hash of the tarball npm downloaded does not match what the lockfile records, so npm decided it cannot trust what arrived and stopped. It is a corrupted cache entry, or a proxy that modified the download, or more rarely a lockfile whose integrity value was hand-edited or badly merged. npm cache clean --force empties the local cache so the next install re-downloads; it deletes only cached copies and is safe to repeat. If it keeps happening for one package, the recorded integrity itself is wrong and that entry has to be re-resolved with npm install.
The fix
npm cache clean --force- Printed by
- npm
- npm
- 20
With npm the cause sits in the first code XXXX line rather than the last six npm ERR! lines, and when the failure comes from the dependency tree or a native build instead of your own code, deleting node_modules and installing again clears about half of them.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “npm ERR! code EINTEGRITY” mean?
The hash of the tarball npm downloaded does not match what the lockfile records, so npm decided it cannot trust what arrived and stopped. It is a corrupted cache entry, or a proxy that modified the download, or more rarely a lockfile whose integrity value was hand-edited or badly merged. npm cache clean --force empties the local cache so the next install re-downloads; it deletes only cached copies and is safe to repeat. If it keeps happening for one package, the recorded integrity itself is wrong and that entry has to be re-resolved with npm install.
Q. How do I fix it?
npm cache clean --force — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
npm. It sits under npm, and the message runs to 4 words.