23

npm ERR! Invalid response body while trying to fetch http://registry.npmjs.org/accepts: Integrity verification failed for <some key i probably shouldn't share>

I get this error on my RPI4 (raspbian) when trying to install angular cli and express. I downgraded to npm 6.13.7 as advised in another thread but no success.

anton broos
  • 277
  • 1
  • 2
  • 9

3 Answers3

62

Try clearing the cache and install again

npm cache clear --force
npm install
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Doodle_coder
  • 736
  • 5
  • 3
  • Thank you. This worked for me, but I wonder why that error even happened? – bytrangle Aug 24 '22 at 04:35
  • In my end, it's done with high privilage: `sudo npm cache clear --force` – Siyavash Hamdi Mar 05 '23 at 23:40
  • Thank you and the first command did it for me. why the second command? the problem was not occurring during install of npm??? Or should I have done an npm install, and why???? you could be more explicit about why clearing the cache and what is being installed so that it is obvious to the user. because I did not need to re-install npm also to clear cache this command was required: sudo chown -R 501:20 "/Users/xuserx/.npm" – TheArchitecta May 11 '23 at 01:31
11

npm cache verify
npm install

The above helped me.
See details in the output of npm cache clean command without --force key.
In my case it was

$ npm cache clean
npm ERR! As of npm@5, the npm cache self-heals from corruption issues
npm ERR! by treating integrity mismatches as cache misses.  As a result,
npm ERR! data extracted from the cache is guaranteed to be valid.  If you
npm ERR! want to make sure everything is consistent, use `npm cache verify`
npm ERR! instead.  Deleting the cache can only make npm go slower, and is
npm ERR! not likely to correct any problems you may be encountering!
npm ERR! 
npm ERR! On the other hand, if you're debugging an issue with the installer,
npm ERR! or race conditions that depend on the timing of writing to an empty
npm ERR! cache, you can use `npm install --cache /tmp/empty-cache` to use a
npm ERR! temporary cache instead of nuking the actual one.
npm ERR! 
npm ERR! If you're sure you want to delete the entire cache, rerun this command
npm ERR! with --force.
it3xl
  • 2,372
  • 27
  • 37
0

Clearing the cache will resolve the issue:

sudo npm cache clear --force
Piyush Chandra
  • 159
  • 1
  • 4