尝试安装@ babel / preset-env时出错

时间:2019-10-18 23:07:20

标签: node.js npm

我正在尝试在节点中安装@ babel / preset-env,并且出现以下问题

npm install @babel/preset-env --save-dev
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha512-PMnY0yhKljgjrP3jQNP5C9slQM//bCLO4ZRr9gmo+2mLkVhCIxhT3A9grgblgLXmOPVd6GFzeIEA6/0g99cxDA== integrity checksum failed when
using sha512: wanted sha512-PMnY0yhKljgjrP3jQNP5C9slQM//bCLO4ZRr9gmo+2mLkVhCIxhT3A9grgblgLXmOPVd6GFzeIEA6/0g99cxDA== but got sha512-IU+YnDh7WJASsz892TYz1eQ+vaEypoAPLmu6DO2Uw2NZzfl/F2ypEL3xrEiIXLU8Buok1TujSujt3bLMmUmysg==. (34788 bytes)
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code EINTEGRITY
npm ERR! errno EINTEGRITY
npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/@babel%2fplugin-transform-member-expression-literals: Integrity verification failed for sha512-PMnY0yhKljgjrP3jQNP5C9slQM//bCLO4ZRr9gmo+2mLkVhCIxhT3A9grgblgLXmOPVd6GFzeIEA6/0g99cxDA== (C:\Users\PRO\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\3c\c9\d8d3284a963823acfde340d3f90bdb2540cfff6c22cee1946bf609a8fb698b915842231853dc0f60ae06e580b5e638f55de86173788100ebfd20f7d7310c)
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\PRO\AppData\Roaming\npm-cache\_logs\2019-10-18T22_56_31_231Z-debug.log

2 个答案:

答案 0 :(得分:0)

尝试这些解决方案之一

  1. npm cache verify --force
  2. 删除packages-lock.json
  3. npm cache clean --force
  4. 删除node_modules

答案 1 :(得分:0)

通常,这意味着您的本地npm缓存或package-lock.json已损坏,导致npm注册表中@babel/preset-env的完整性哈希与{{1}中的内容不同}。我将按此顺序执行这些步骤。

  1. package-lock.json
  2. rm -rf node_modules
  3. rm package-lock.json
  4. npm cache clean -f
  5. npm cache verify -f

这将删除您拥有的所有缓存数据,并迫使npm登录注册表以获取新的软件包数据,并重新生成npm i以使用更新的完整性哈希。

相关问题