我有一个在GIT仓库中版本化的nodejs项目。当我克隆项目时,将包含package-lock.json(应该如此),但是当我执行“ npm install”时,出现错误Unhandled rejection Error: Integrity check failed
如果我删除package-lock.json一切正常
Package.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)
答案 0 :(得分:2)
尝试npm cache verify
或npm cache --force clean
。然后尝试npm install
。它对我有用。
答案 1 :(得分:1)
引起问题的软件包是我的本地模块。我有另一个项目,在该项目中,我总是使用相同的名称“ localmodule-1.1.1.tgz”来打包模块。 该模块的校验和存储在package-lock.json中。 当我更改模块的内容而不是名称时,npm会检测到我正在尝试安装相同的模块,但校验和不匹配。
答案 2 :(得分:0)
要添加到OP的答案中,我的错误是客户端生成的私有npm软件包,我首先必须使用npm i <path to client package>
重新安装。重新安装后,我能够运行npm i
并成功更新所有其他软件包。
答案 3 :(得分:0)
今天有一个相同的问题,并降落在此页面上。上面的东西对我来说不起作用,但是经过一段时间的修复后,通过做一些小事..因此将其发布..可能对其他人有帮助。
只需删除“ package-lock.json”文件并执行npm install ...:)