Angluar在执行安装命令npm install -g @angular/cli 时,出现如下错误:
C:\Windows\System32>npm install -g @angular/cli
npm ERR! code EAI_AGAIN
npm ERR! errno EAI_AGAIN
npm ERR! request to https://registry.npmjs.org/@angular%2fcli failed, reason: ge
taddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\tom\AppData\Roaming\npm-cache\_logs\2019-02-28T01_42_
43_882Z-debug.log
在网上查找了众多的解决方法,都不能解决问题,后来在stackoverflow上看到一个帖子,参照帖子给出的方案,完美解决问题,解决方案如下:
步骤1. 执行npm config edit --g 命令打开配置文件nmprc
C:\Windows\System32>npm config edit --g
步骤2:修改如下配置
; registry=https://registry.npmjs.org/ -- 去掉';',放开配置
; proxy=null 修改为局域网的代码配置 proxy=http://proxy.xxxx.com.cn:port
; strict-ssl=true -- 去掉';',放开配置
步骤3:保存配置
然后在命令行窗口重新执行安装命令:
C:\Windows\System32>npm install -g @angular/cli
安装成功,界面显示如下:
C:\Windows\System32>npm config edit --g
C:\Windows\System32>npm install -g @angular/cli
C:\Users\tom\AppData\Roaming\npm\ng -> C:\Users\tom\AppData\Roaming\np
m\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\@an
gular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@
1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}
)
+ @angular/cli@7.3.3
added 295 packages from 179 contributors in 169.265s