【问题标题】:NPM is giving me an error using npm installNPM 使用 npm install 给我一个错误
【发布时间】:2020-07-16 20:00:53
【问题描述】:

一位朋友与我分享了他正在为 WordPress 开发的主题,我将他的 repo 克隆到我的 /themes 文件夹中,我尝试的第一件事是在主题文件夹中运行“npm install”以获得 gulp 和其他 npm很酷的功能。

这是它返回的内容:

$ npm install
npm ERR! code EINTEGRITY
npm ERR! sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= integrity checksum failed when using sha1: wanted sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= but got sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=. (36808 bytes)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rinor\AppData\Roaming\npm-cache\_logs\2020-04-04T17_30_54_859Z-debug.log

在尝试全局安装它后,它给了我同样的错误,所以我想出了从我的电脑上卸载 node.js,然后下载并安装 LTS 版本 (12.16.1)。重新启动,测试,当我尝试输入“node -v”&&“npm -v”时它似乎工作。但是当我回到我的主题并选择“npm install”时,它给了我同样的错误。

这是我的 package.json 内容

{
  "name": "ruce-theme",
  "version": "1.0.0",
  "description": "A starter theme",
  "scripts": {
    "watch": "gulp watch"
  },
  "dependencies": {
    "bootstrap": "^4.0.0-beta.3",
    "jquery": "^3.2.1",
    "npm": "^6.4.1",
    "slick-carousel": "^1.8.1"
  },
  "devDependencies": {
    "@babel/core": "^7.3.3",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^8.0.5",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-env": "^1.6.0",
    "cross-env": "^5.0.1",
    "css-loader": "^2.1.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^3.0.1",
    "gulp": "^4.0.0",
    "gulp-babel": "^8.0.0-beta.2",
    "gulp-clean-css": "^3.9.1",
    "gulp-clone": "^1.1.4",
    "gulp-concat": "^2.6.1",
    "gulp-cssnano": "^2.1.2",
    "gulp-ignore": "^2.0.2",
    "gulp-imagemin": "^4.0.0",
    "gulp-merge": "^0.1.1",
    "gulp-plumber": "^1.2.0",
    "gulp-rename": "^1.2.2",
    "gulp-rimraf": "^0.2.2",
    "gulp-sass": "^3.1.0",
    "gulp-sequence": "^0.4.6",
    "gulp-sourcemaps": "2.6.2",
    "gulp-uglify": "^3.0.0",
    "gulp-watch": "^4.3.11",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.29.0",
    "webpack-cli": "^3.2.1"
  },
  "license": "ISC"
}

这些是调试显示的错误

20111 error code EINTEGRITY
20112 error sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= integrity checksum failed when using sha1: wanted sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= but got sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=. (36808 bytes)
20113 verbose exit [ 1, true ]

【问题讨论】:

标签: node.js npm


【解决方案1】:

你没有提到你是否有package-lock.json。在某些情况下,以下可能会有所帮助。但首先要确保你了解发生了什么。 npm 告诉您来自https://registry.npm.org 的校验和与来自package-lock.json 的校验和不匹配。要么在注册表中更改,要么...

解决方案考虑输出中的行:

npm ERR!
  sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc=
integrity checksum failed when using sha1: wanted
  sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc=
but got
  sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
. (36808 bytes)

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

更多信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2018-02-26
    • 1970-01-01
    • 2020-08-14
    • 2018-10-17
    • 1970-01-01
    相关资源
    最近更新 更多