简体   繁体   English

npm无法安装angular-cli

[英]npm Unable to Install angular-cli

I am trying to install angular-cli via npm. 我正在尝试通过npm安装angular-cli。 I have the recent version of Nodejs and git installed. 我安装了最新版本的Nodejs和git。 I am not behind any proxy server(verified it through netsh winhttp show proxy as well as through Internet Explorer LAN settings) and there is no problem with my internet connection. 我没有任何代理服务器(通过netsh winhttp show proxy以及Internet Explorer LAN设置对其进行了验证),并且我的Internet连接没有问题。 When i try to run 当我尝试跑步

npm install -g angular-cli then I get the following error 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

I tried cleaning the cache through npm cache clean and also tried to change the registry to http:\\ via 我尝试通过npm cache clean ,还尝试通过以下方式将注册表更改为http:\\

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

I also tried uninstalling nodejs and reinstalling it again but it is not working. 我还尝试了卸载nodejs并再次重新安装它,但是它不起作用。 I am getting the same error. 我遇到了同样的错误。 Any ideas. 有任何想法吗。

Setp-1: open windows command prompt then type following command to get the IP address of your proxy server SETP-1:打开Windows命令提示符,然后键入以下命令以获取代理服务器的IP地址

ping your-proxy-name

For example: 例如:

ping myproxy.xyz.com

Step-2: open Node.js command prompt and type following command 步骤2:打开Node.js命令提示符并键入以下命令

npm config set http-proxy http://your-proxy-ip-retrieved-in-step-1:port
npm config set https-proxy http://your-proxy-ip-retrieved-in-step-1:port

For example: 例如:

npm config set http-proxy http://192.168.192.95:8080
npm config set https-proxy http://192.168.192.95:8080

Setp-3: on Node.js command prompt type following command to install angular Setp-3:在Node.js命令提示符下,键入以下命令以安装angular

npm install -g @angular/cli

Hope it will work for you. 希望它对您有用。

Yes, this can be caused either by a firewall or a proxy. 是的,这可能是由防火墙或代理引起的。 Can you ping the npm registry host and fetch a simple file? 您可以ping npm注册表主机并获取一个简单的文件吗?

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

If the ping is not successful, check your connection or disable your firewall . 如果ping不成功,请检查您的连接或禁用防火墙

This kind of issues usually happen when you are behind a proxy or a firewall that blocks npm from fetching the requested packaged. 当您位于代理或防火墙后面,阻止npm提取请求的打包数据时,通常会发生此类问题。

If you know your proxy address and port, open a console and set your HTTP_PROXY and HTTPS_PROXY variables before running npm, as follows: 如果知道代理地址和端口,请在运行npm之前打开控制台并设置HTTP_PROXY和HTTPS_PROXY变量,如下所示:

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

npm install <package_name>

Future viewers: Try below approach (it worked for me) 未来的观众:尝试以下方法(对我有用)

Go to nodejs installed location (path may be different in your case) 转到nodejs的安装位置(您的情况下路径可能有所不同)
C:\\Program Files\\nodejs\\node_modules\\npm C:\\ Program Files \\ nodejs \\ node_modules \\ npm

Add below entry in the npmrc file then save it 在npmrc文件中添加以下条目,然后保存

strict-ssl=false

Then try installing angular cli 然后尝试安装角度cli

npm install -g @angular/cli

I faced similar issues and figured that we need to combine the proxy and the install command together like below and it worked for me. 我遇到了类似的问题,并认为我们需要将代理和安装命令结合在一起,如下所示,并且它对我有用。 Hope it works for you people. 希望它为您服务。 Thanks!! 谢谢!!

npm --proxy http://username:password@proxyURL:port install -g @angular/cli --without-ssl --insecure npm --proxy http://用户名:密码@proxyURL:端口安装-g @ angular / cli --without-ssl-不安全

You need to override your proxy settings to install angular CLI. 您需要覆盖代理设置才能安装角度CLI。 Try executing below command : 尝试执行以下命令:

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

This will override your proxy and you do not need to make any changes to your connections or firewall. 这将覆盖您的代理,并且您不需要对连接或防火墙进行任何更改。 Once this command executes successfully try installing angular CLI using below command: 成功执行此命令后,请尝试使用以下命令安装角度CLI:

npm install -g @angular/cli

Refer this link for more details on this. 有关更多详细信息,请参考此链接

This solved problems for me. 这为我解决了问题。 Hope this helps! 希望这可以帮助!

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

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