尝试安装 @babel/预设环境时出错



>我正在尝试在节点中安装 @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:UsersPROAppDataRoamingnpm-cache_cacachecontent-v2sha5123cc9d8d3284a963823acfde340d3f90bdb2540cfff6c22cee1946bf609a8fb698b915842231853dc0f60ae06e580b5e638f55de86173788100ebfd20f7d7310c)
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersPROAppDataRoamingnpm-cache_logs2019-10-18T22_56_31_231Z-debug.log

试试这些解决方案之一

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

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

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

这应该会删除您拥有的任何缓存数据,并强制 npm 访问注册表以获取新的包数据,并重新生成package-lock.json以使用更新的完整性哈希。

最新更新