npm - 使用陈旧的包数据
Posted
技术标签:
【中文标题】npm - 使用陈旧的包数据【英文标题】:npm - using stale package data 【发布时间】:2018-01-15 03:25:53 【问题描述】:每当我执行 npm 安装时,我都会使用陈旧的包数据收到大量关于它的消息。这是什么意思,我需要担心吗?
这是我在安装 npm 时收到的警告消息的一个小示例。在这个特定的示例中,我刚刚添加了“npm install @angular/animations@latest --save”:
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0
g== integrity checksum failed when using sha512: wanted sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g== but got sha1-2+xJQ20q4V9TYRTnbRRlbNvA9E0
=. (8538 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUu
g== integrity checksum failed when using sha512: wanted sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug== but got sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g
=. (3618 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0
g== integrity checksum failed when using sha512: wanted sha512-Mp+FXEI+FrwY/XYV45b2YD3E8i3HwnEAoFcM0qlZzq/RZ9RwWitt2Y/c7cqRAz70U7hfekqx6qNYthuKFO6K0g== but got sha1-2+xJQ20q4V9TYRTnbRRlbNvA9E0
=. (8538 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUu
g== integrity checksum failed when using sha512: wanted sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug== but got sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g
=. (3618 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
这是我的项目当前的 package.json 文件:
"name": "myproject",
"version": "0.0.1",
"license": "me",
"scripts":
"ng": "ng",
"start": "ng serve",
"build": "ng build --extract-css true",
"build-prod": "ng build -prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"update:packages": "node wipe-dependencies.js && rm -rf node_modules && npm update --save-dev && npm update --save",
"prestyleguide": "ng build --extract-css true",
"styleguide": "rimraf dist/styleguide/ && kss --config kss/kss-config.json --custom hidemarkup --custom hideexample --custom hidedefault --custom fakeexample --placeholder .modifier-class",
"//": "Build just the styleguide without building the entire app (requires that the app has already been built to the dist/ folder)",
"build-styleguide": "rimraf dist/styleguide/ && kss --config kss/kss-config.json --custom hidemarkup --custom hideexample --custom hidedefault --custom fakeexample --placeholder .modifier-class"
,
"private": true,
"dependencies":
"@angular/animations": "^4.3.3",
"@angular/common": "^4.3.2",
"@angular/compiler": "^4.3.2",
"@angular/core": "^4.3.2",
"@angular/forms": "^4.3.2",
"@angular/http": "^4.3.2",
"@angular/platform-browser": "^4.3.2",
"@angular/platform-browser-dynamic": "^4.3.2",
"@angular/router": "^4.3.2",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.28",
"bootstrap": "^4.0.0-alpha.6",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"ngx-mydatepicker": "^2.0.12",
"rxjs": "^5.4.2",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.16"
,
"devDependencies":
"@angular/cli": "^1.2.3",
"@angular/compiler-cli": "^4.3.2",
"@types/jasmine": "^2.5.53",
"@types/node": "^8.0.15",
"codelyzer": "^3.1.2",
"fs-extra": "^4.0.0",
"jasmine-core": "^2.6.4",
"jasmine-spec-reporter": "^4.1.1",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"kss": "^3.0.0-beta.18",
"protractor": "^5.1.2",
"random-ext": "^2.5.1",
"ts-node": "^3.2.1",
"tslint": "^5.5.0",
"typedoc": "^0.7.1",
"typescript": "^2.4.2"
【问题讨论】:
【参考方案1】:尝试一下,然后重新安装项目的所有依赖项
rm ./package-lock.json
rm -r ./node_modules
npm cache clear --force
github上有一个full thread关于它,我认为从六月开始
【讨论】:
我不明白每个人都建议删除 package-lock.json 是一种解决方案。通过这样做,您将首先删除 package-lock.json 的所有保证 @Rhys 是否意味着我们只需要删除节点模块文件夹然后清除 npm 缓存? 如果您的锁仍然没问题,它应该可以工作。你只需要尝试。如果能解决问题,那就太好了。如果不重试并删除 .lock 也 @Rhyspackage-lock.json
在npm install
期间重新生成。所以在我的情况下,package-lock.json
被替换,而不是被删除。 (这就解决了问题。)
我很想回答 OP 的问题:“这是什么意思,我需要担心吗?”有人吗?【参考方案2】:
由于 npm 5 您无法完全控制缓存,因此对于 npm 5 您可以尝试
npm cache verify
这对我有帮助。我认为您不必首先删除 package-lock 和 node_modules 。
【讨论】:
【参考方案3】:如果缓存清除方法不起作用...
我发现我在 OS X 更新期间遇到了这个问题。安装命令行工具更新并重新启动 iTerm 解决了这个问题,令人难以置信。
当然不是暗示这是一个“正确”的解决方案,但肯定会弄乱我的设置(wtf apple?)。发布在其他查看此内容的人处于相同位置的情况下??
【讨论】:
我在更改防火墙设置后解决了这个问题。如果接受的解决方案不起作用,只需添加此内容以供参考。【参考方案4】:您可以尝试使用以下方法清除 NPM 缓存:
$ npm cache clear --force
然后重新安装你的节点模块。
我希望这会有所帮助。
【讨论】:
【参考方案5】:我在使用自定义注册表(不是npmjs.org
)时收到此错误。问题是我的注册表已关闭。
【讨论】:
【参考方案6】:在删除您的 node_modules
之前,请检查您的互联网连接 - 您的提供商可能会进行一些流量整形并阻止或减慢对软件包存储库的访问。如果您在错误消息中看到类似 Miscellaneous Warning ETIMEDOUT: [...]
的内容,您就会发现这一点。
我就是这种情况,使用 *** 后问题就解决了。
【讨论】:
以上是关于npm - 使用陈旧的包数据的主要内容,如果未能解决你的问题,请参考以下文章