npm ERR! npm安装时代码EINTEGRITY

时间:2019-09-18 10:05:02

标签: node.js reactjs npm npm-install

当我尝试安装npm时,出现此错误

  npm ERR! code EINTEGRITY
    npm ERR! 
    sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA== 
    integrity checksum failed when using sha512: wanted sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA== but got sha5
        12-jGhWI9FADblpQKmyQF4BghrHs6FLV3dYFHVWcvj0xIUzHuO41PPfUlZOUplwasz72FRE2Knsa0wWubWldC9Jpw==. (3240 bytes)
        npm WARN tar invalid entry
        npm WARN tar invalid entry
        npm WARN tar invalid entry
        npm WARN tar invalid entry
        npm WARN tar invalid entry
        npm WARN tar invalid entry

我尝试过

npm cache verify
npm cache clean --force

我已经删除了package-lock.json文件,

将代理添加到.npmrc和其他conf,例如strict-ssl = false, NODE_TLS_REJECT_UNAUTHORIZED = 0

版本:

npm version
{ npm: '6.11.3',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  modules: '64',
  napi: '4',
  nghttp2: '1.39.2',
  node: '10.16.3',
  openssl: '1.1.1c',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.28.0',
  v8: '6.8.275.32-node.54',
  zlib: '1.2.11' }

node -v
v10.16.3

2 个答案:

答案 0 :(得分:0)

您删除了package-lock.json,因此以下内容可能对您毫无用处。就我而言,它奏效了。但是首先请确保您了解发生了什么。 npm告诉您https://registry.npm.org的校验和与package-lock.json的校验和不匹配。要么在注册表中更改了,要么...

考虑输出中的一行:

npm ERR! 
  sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA== 
integrity checksum failed when using sha512: wanted
  sha512-boQj1WFgQH3v4clhu3mTNfP+vOBxorDlE8EKiMjUlLG3C4qAESnn9AxIOkFgTR2c9LtzNjPrjS60cT27ZKBhaA==
but got
  sha512-jGhWI9FADblpQKmyQF4BghrHs6FLV3dYFHVWcvj0xIUzHuO41PPfUlZOUplwasz72FRE2Knsa0wWubWldC9Jpw==
. (3240 bytes)

通过前两个完整性校验和(package-lock.json)在sha512-b...中找到包,然后将第三个(sha512-j...)放入其“完整性”字段中。

更多here

答案 1 :(得分:0)

以下是对我有用的解决方案:

  1. 删除node_modules文件夹和package-lock.json

    rm -rf node_modules package-lock.json

  2. 安装npm

    npm install