npm无法安装angular-cli

我正在尝试通过npm安装angular-cli。 我有最近版本的Nodejs和git安装。 我不在任何代理服务器后面(通过netsh winhttp show proxy以及通过Internet Explorer局域网设置进行validation),并且我的Internet连接没有问题。 当我尝试运行

npm install -g angular-cli然后我得到以下错误

 C:\Windows\system32>npm install -g angular-cli npm ERR! Windows_NT 6.1.7601 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 v7.3.0 npm ERR! npm v3.10.10 npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! syscall connect npm ERR! network connect ETIMEDOUT 151.101.192.162:80 npm ERR! network This is most likely not a problem with npm itself npm ERR! network and is related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settin gs. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm ERR! Please include the following file with any support request: npm ERR! C:\Windows\system32\npm-debug.log 

我尝试通过npm cache clean ,并试图将registry更改为http:\ via

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

我也尝试卸载nodejs并重新安装它,但它不工作。 我得到同样的错误。 有任何想法吗。

是的,这可能是由防火墙或代理引起的。 你可以ping npmregistry主机并获取一个简单的文件?

 > ping registry.npmjs.org > npm view npm version 

它的ping不成功检查您的连接或禁用您的防火墙

否则,如果它的工作,所以更新npm

这种问题通常发生在当代理或防火墙阻止npm获取请求的打包时。

如果您知道您的代理地址和端口,请在运行npm之前打开控制台并设置您的HTTP_PROXY和HTTPS_PROXYvariables,如下所示:

 set HTTP_PROXY = "http://<proxy server name or IP address>:<proxy port>" set HTTPS_PROXY = ... ;same as above npm install <package_name> 

未来的观众:尝试下面的方法(它为我工作)

转到nodejs安装的位置(path可能会在你的情况下不同)
C:\ Program Files \ nodejs \ node_modules \ npm

在npmrc文件中添加以下条目然后保存

 strict-ssl=false 

然后尝试安装angular度cli

 npm install -g @angular/cli 

我面临类似的问题,并认为我们需要将代理和安装命令结合在一起,如下所示,它为我工作。 希望它适合你的人。 谢谢!!

npm –proxy http://用户名:密码@ proxyURL:端口安装-g @ angular / cli –without-ssl –insecure