简体   繁体   English

为什么 npm 会抛出错误“安装@angular/cli 时校验和失败”?

[英]Why is npm throwing the error “checksum failed while installing @angular/cli”?

I'm using node v6.11.5 and npm 3.10.10 and 64-bit OS, and while installing @angular/cli I'm getting the following error:我正在使用 node v6.11.5 和 npm 3.10.10 和 64 位操作系统,在安装 @angular/cli 时出现以下错误:

C:\WINDOWS\system32>npm install -g @angular/cli
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10

npm ERR! shasum check failed for C:\Users\Shubham\AppData\Local\Temp\npm-6192-9e
acb63c\registry.npmjs.org\rxjs\-\rxjs-5.5.2.tgz
npm ERR! Expected: 28d403f0071121967f18ad665563255d54236ac3
npm ERR! Actual:   c2b697120c7dc0e6728da0e7636b90e15723cc24
npm ERR! From:     http://registry.npmjs.org/rxjs/-/rxjs-5.5.2.tgz
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\WINDOWS\system32\npm-debug.log

I'm trying to solve this since last night, but each time this shasum check failed is all I'm getting.我从昨晚开始就试图解决这个问题,但是每次这个 shasum 检查失败都是我得到的。 I tried the following things:我尝试了以下几件事:

  1. I configured the npm registry to both http and https.我将 npm 注册表配置为 http 和 https。 Didn't worked.没用。
  2. Checked the path OS path variables, and the directory where node is installed.检查路径操作系统路径变量,以及安装节点的目录。 Found nothing.什么也没找到。
  3. Tried to clean npm and uninstalling and installing angular/cli.尝试清理 npm 并卸载和安装 angular/cli。 Didn't worked.没用。

Local setup issues are tough to debug as there's a lot of trial and error, keeping a list of what you've tried and resulting outcomes.本地设置问题很难调试,因为有很多反复试验,保留了您尝试过的内容和结果的列表。

This is an attempt at a list of suggestions.这是对建议列表的尝试。 I suspect you've tried many of these, I hope this helps organize your efforts.我怀疑你已经尝试了很多,我希望这有助于组织你的努力。

  1. Verify npm registry : npm get registry (expect: https://registry.npmjs.org/ )验证 npm注册表npm get registry (期望: https : npm get registry
  2. Update npm to latest: npm install npm@latest -g将 npm 更新为最新: npm install npm@latest -g
  3. Remove package-lock.json删除package-lock.json
  4. Uninstall npm completely before reinstalling , including npm and npm-cache directories: sudo npm uninstall npm -g重新安装之前完全卸载npm,包括 npm 和 npm-cache 目录: sudo npm uninstall npm -g
  5. Uninstall node completely (including npm again) and reinstalling完全卸载节点(再次包括 npm)并重新安装

Along the way, I did come across similar github issues:一路上,我确实遇到了类似的github问题:

Hi @Rogasch I will suggest you to completely uninstall node and npm.嗨@Rogasch 我会建议你完全卸载 node 和 npm。 Also delete npm and npm-cache folder.同时删除 npm 和 npm-cache 文件夹。 And reinstall using node-v6.11.2-x86.msi installer.并使用 node-v6.11.2-x86.msi 安装程序重新安装。 👍 3 ❤️ 1 👍 3 ❤️ 1

i had the same issue and npm install -g npm fixed it for me我遇到了同样的问题, npm install -g npm 为我修复了它

I got this problem when I got package-lock.json included in the commit.当我在提交中包含 package-lock.json 时,我遇到了这个问题。 After removing package-lock.json I could run npm install without errors again.删除 package-lock.json 后,我可以再次无错误地运行 npm install。

it's a build problems on windows, try these steps:这是 Windows 上的构建问题,请尝试以下步骤:

npm install -g node-gyp

npm install --global windows-build-tools

npm install -g angular-cli

我删除了package-lock.json文件并重新运行npm install

在我们的Ubuntu 18.04 上,我们只需要执行以下操作:

npm install npm@latest -g

通过转到%AppData%删除npmnpm-cache试它会正常工作

For me, my registry address was having http instead of https.对我来说,我的注册地址是 http 而不是 https。 When I checked my registry address with,当我检查我的注册地址时,

npm check registry 

I saw http://registry.npmjs.org/ .我看到了http://registry.npmjs.org/ I changed my registry address with https version我用 https 版本更改了我的注册地址

npm config set https://registry.npmjs.org/

And all the problems went away.所有的问题都迎刃而解。

Run powershell as an administrator and then run these commands.以管理员身份运行 powershell,然后运行这些命令。

npm cache clean --force

npm install -g @angular/cli

重新安装节点,然后安装最新版本的angular cli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM