node.js - npm 安装问题... npm ERR!代码 E400
问题描述
首先,我安装了最新版本的 angular cli。然后,当我尝试降级到 7.3.3 时出现错误: 400 Bad Request - GET https://github.com/。我也无法使用 npm install 安装任何东西,比如 node-sass 等。所以我卸载了 nodejs 并尝试再次安装 angular cli,但出现了同样的错误。也许我改变了任何配置。
命令
C:\Windows\system32>node -v
v12.17.0
C:\Windows\system32>npm install -g @angular/cli
npm ERR! code E400
npm ERR! 400 Bad Request - GET https://github.com/
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XXXX\AppData\Roaming\npm-cache\_logs\2020-06-01T10_49_37_560Z-debug.log
日志
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '@angular/cli'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.17.0
4 verbose npm-session bc2383db262e35f5
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 400 https://github.com/ 506ms
8 silly fetchPackageMetaData error for @angular/cli@latest 400 Bad Request - GET https://github.com/
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 543ms
11 verbose stack Error: 400 Bad Request - GET https://github.com/
11 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:104:15
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
12 verbose statusCode 400
13 verbose pkgid @angular/cli@latest
14 verbose cwd C:\Windows\system32
15 verbose Windows_NT 10.0.17763
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
17 verbose node v12.17.0
18 verbose npm v6.14.4
19 error code E400
20 error 400 Bad Request - GET https://github.com/
21 verbose exit [ 1, true ]
解决方案
1.>去你的这个位置
C:\Users\{your user name or ID}
2.> 打开 .npmrc 并从 .npmrc 文件中删除所有内容。
3.>重新打开你的新命令提示符
4.>再次运行代码,就可以了。
推荐阅读
- google-apps-script - 如何使用 Google Apps 脚本在 Google 幻灯片中设置形状的透明度/不透明度和颜色?
- python - 添加或复制现有的交叉表 pandas
- xamarin.forms - 带有参数的 Xamarin.Forms Shell 导航层次结构
- python - 计算所有列 pandas 的滚动平均值
- python-3.x - 使用Python逐行提取href而不是整个表
- html - 为什么我没有看到使用 django 的 html 中的所有部分
- c - Malloc 中的编译错误
- angular - 如何将 Spring Boot Rest 服务和 Angular App 捆绑在一个 war 文件中
- sql - 在进入新的一年时找出上个月的数据
- reactjs - 使用反应钩子将状态中的现有对象替换为另一个对象