首页 > 解决方案 > 在 npm Install 我收到“未处理的拒绝错误:完整性检查失败”,但是当我删除 package-lock.json 时,错误消失了

问题描述

我有一个在 GIT 存储库中版本化的 nodejs 项目。当我克隆项目时,包含 package-lock.json(应该如此)但是当我执行“npm install”时出现错误Unhandled rejection Error: Integrity check failed

如果我删除 package-lock.json 一切正常

包.json:

"dependencies": {
    "aws-sdk": "^2.258.1",
    "localmodule": "file:../LocalModule/dist/localmodule-1.1.1.tgz"
  },
  "devDependencies": {
    "@types/chai": "^4.1.4",
    "@types/mocha": "^5.2.2",
    "@types/node": "^10.3.2",
    "@types/sinon": "^5.0.1",
    "aws-sdk-mock": "^2.0.0",
    "chai": "^4.1.2",
    "merge2": "^1.2.2",
    "mocha": "^5.2.0",
    "nps": "^5.9.2",
    "nps-utils": "^1.6.0",
    "sinon": "^5.0.10",
    "sinon-chai": "^3.1.0",
    "ts-node": "^6.1.1",
    "typescript": "^3.1.6"
  }

完整错误:

Unhandled rejection Error: Integrity check failed:from@0.1.7 extracted to /home/...
  Wanted: sha512-atI2DklW/phzBW2RyPznpbepvl1aRh7Y0XHfguqv...
   Found: sha512-9BeJ7UP5OY9cUDsNXlHaYL6Xqd1cARifioOEtF60...
    at checksumError (/usr/lib/node_modules/npm/node_modules/cacache/lib/content/write.js:157:13)
    at write (/usr/lib/node_modules/npm/node_modules/cacache/lib/content/write.js:35:22)
    at putData (/usr/lib/node_modules/npm/node_modules/cacache/put.js:29:10)
    at Object.x.put (/usr/lib/node_modules/npm/node_modules/cacache/locales/en.js:28:37)
    at readFileAsync.then.data (/usr/lib/node_modules/npm/node_modules/pacote/lib/fetchers/file.js:38:28)
    at tryCatcher (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:694:18)
    at Promise._fulfill (/usr/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
    at /usr/lib/node_modules/npm/node_modules/bluebird/js/release/nodeback.js:42:21
    at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

标签: node.jsnpm

解决方案


导致问题的包是我的本地模块。我有另一个项目,我总是用相同的名称“localmodule-1.1.1.tgz”打包模块。该模块的校验和存储在 package-lock.json 中。当我更改模块的内容而不是名称时,npm 检测到我正在尝试安装相同的模块,但校验和不匹配。


推荐阅读