Angular 安装cli问题完美解决方法

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

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值