我有一个在 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"
}
Run Code Online (Sandbox Code Playgroud)
完整错误:
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)
Run Code Online (Sandbox Code Playgroud)
导致问题的包是我的本地模块。我有另一个项目,我总是使用相同的名称“localmodule-1.1.1.tgz”打包模块。该模块的校验和存储在 package-lock.json 中。当我更改模块的内容而不是名称时,npm 检测到我正在尝试安装相同的模块但校验和不匹配。
小智 7
今天有同样的问题并登陆此页面。上述事情对我不起作用,但一段时间后通过做一些小工作修复了它..因此发布它..可能对其他人有帮助。
只需删除“package-lock.json”文件并执行 npm install...:)