Node.js 代理配置后无法npm安装Angular cli

Node.js 代理配置后无法npm安装Angular cli,node.js,angular,proxy,npm-install,Node.js,Angular,Proxy,Npm Install,我正在尝试使用npm安装在Windows10中下载Angular。由于我使用公司代理,我将代理配置为用户名:password@server:端口 然而,我在跑步时面临着这个问题 npm错误!代码E407 npm错误!407需要代理授权:@angular/cli@latest 调试日志如下所示: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose c

我正在尝试使用npm安装在Windows10中下载Angular。由于我使用公司代理,我将代理配置为用户名:password@server:端口

然而,我在跑步时面临着这个问题

npm错误!代码E407
npm错误!407需要代理授权:@angular/cli@latest

调试日志如下所示:

0 info it worked if it ends with ok
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   '--proxy',
1 verbose cli   'http://XXXXX',     //Removed my proxy details
1 verbose cli   '--without-ssl',
1 verbose cli   '--insecure',
1 verbose cli   '-g',
1 verbose cli   'install',
1 verbose cli   '@angular/cli' ]
2 info using npm@5.4.2
3 info using node@v8.8.1
4 verbose npm-session 40ab1dc3dabb6029
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 407 http://registry.npmjs.org/@angular%2fcli 109ms
8 silly fetchPackageMetaData error for @angular/cli@latest 407 Proxy Authorization Required: @angular/cli@latest
9 verbose stack Error: 407 Proxy Authorization Required: @angular/cli@latest
9 verbose stack     at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
9 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
9 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
9 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
9 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
9 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
9 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
9 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
9 verbose stack     at Immediate.Async.drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
9 verbose stack     at runCallback (timers.js:785:20)
9 verbose stack     at tryOnImmediate (timers.js:747:5)
9 verbose stack     at processImmediate [as _immediateCallback] (timers.js:718:5)
10 verbose cwd C:\Users\XXXXX
11 verbose Windows_NT 10.0.14393
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--proxy" "http://XXXXX" "--without-ssl" "--insecure" "-g" "install" "@angular/cli"
13 verbose node v8.8.1
14 verbose npm  v5.4.2
15 error code E407
16 error 407 Proxy Authorization Required: @angular/cli@latest
17 verbose exit [ 1, true ]

知道是什么导致了这个问题吗?谢谢

尝试将npm注册表的URL设置为http而不是https。你可以看看这个。

这个配置对我很有用:

method1(命令行):

npm config set proxy http://user:password@domain_proxy:port/
npm config set https-proxy http://user:password@domain_proxy:port

be careful the url should be encoded. for example this password 01xx!tr should be introduced as 01xx%21tr. use this site to encode your url https://www.url-encode-decode.com/

example:
user/password => user1/01xx!tr
domain:port of the proxy => mydomain.org:8000
=> in that case :

npm config set proxy http://user1:01xx%21tr@mydomain.org:8000/
npm config set https-proxy http://user1:01xx%21tr@mydomain.org:8000
the method 2 is easier because we will not be botherd with encoding the urls

1- edit node configuration file (in windows it's located in %USERPROFILE%\.npmrc, example C:\Users\Jack\.npmrc)

2- add these lines
proxy=http://user:password@domain_proxy:port/
https-proxy=https-proxy http://user:passwor`enter code here`d@domain_proxy:port

example :
if the :
user/password => user1/01xx!tr
domain:port of the proxy => mydomain.org:8000

=> the configuration file should be look like this:

proxy=http://user1:01xx!tr@mydomain.org:8000/
https-proxy=http://user1:01xx!tr@mydomain.org:8000
method2(编辑节点合并文件):

npm config set proxy http://user:password@domain_proxy:port/
npm config set https-proxy http://user:password@domain_proxy:port

be careful the url should be encoded. for example this password 01xx!tr should be introduced as 01xx%21tr. use this site to encode your url https://www.url-encode-decode.com/

example:
user/password => user1/01xx!tr
domain:port of the proxy => mydomain.org:8000
=> in that case :

npm config set proxy http://user1:01xx%21tr@mydomain.org:8000/
npm config set https-proxy http://user1:01xx%21tr@mydomain.org:8000
the method 2 is easier because we will not be botherd with encoding the urls

1- edit node configuration file (in windows it's located in %USERPROFILE%\.npmrc, example C:\Users\Jack\.npmrc)

2- add these lines
proxy=http://user:password@domain_proxy:port/
https-proxy=https-proxy http://user:passwor`enter code here`d@domain_proxy:port

example :
if the :
user/password => user1/01xx!tr
domain:port of the proxy => mydomain.org:8000

=> the configuration file should be look like this:

proxy=http://user1:01xx!tr@mydomain.org:8000/
https-proxy=http://user1:01xx!tr@mydomain.org:8000

如果您已经配置了代理,但仍然无法使用npm命令进行安装。你可以试试下面的命令。看起来你需要清理一些东西,这将解决问题

npm cache verify

这个步骤对我很有效

编辑
.npmrc
文件 添加以下行

proxy=http://username:password@proxyaddress:portno
https-proxy=http://username:password@proxyaddress:portno

对我有用的东西如下, 问题:在“C:\Users*用户名*.npmrc”处定义的注册表错误。需要更新npm配置注册表

第一步 解决方案:从“C:\Users*用户名*.npmrc”文件中删除注册表项

步骤2 在第一步之后,我得到了下面的错误

npm安装-g@angular/cli npm WARN注册表意外警告:杂项警告\u链中的自签名\u证书:请求失败,原因:证书链中的自签名证书 由于重新验证期间的请求错误,npm使用来自的过时包数据警告注册表

问题:npm维护人员于2月27日宣布,npm的自签名证书不再是: 今天,一群用户在安装和发布软件包的过程中收到了一个“SELFSIGNEDCERTINCHAIN”错误。npm不再支持其自签名证书。 但是,建议的修复对我来说失败了

解决方案:打开命令提示符,然后运行下面的命令。 SETLOCAL 设置npm\u config\u strict-ssl=false npm安装npm-g--ca=null npm——版本 端部

步骤3
现在>npm安装-g@angular/cli运行正常。

要在office中配置代理

npm config set proxy http://user:password@proxy.companyname.com:port/
npm config set https-proxy http://user:password@proxy.companyname.com:port/
解决了。 在我花了一点时间讨论代理问题之后,我发现我的错误是设置了3个代理变量:proxyhttp-proxyhttps-proxy

(注意:我在stackoverflow上的某个地方读到我应该设置http代理,但这是错误的)

删除http代理为我解决了这个问题

设置npm代理和npm https_代理是正确的,如下所示:

npm config set proxy http://user:password@proxy.companyname.com:port/
npm config set https-proxy http://user:password@proxy.companyname.com:port/

能否将更改为http后显示的错误日志文件放在此处?[原因:getaddrinfo EAI_再次:80]表示存在DNS解析问题。请检查公司代理配置的代理和端口。许多人使用8080作为代理端口。如果将端口更改为8080,我得到的错误与我以前得到的相同。谢谢基本上您需要检查为您的公司网络配置的代理端口。8080可能不是您公司代理的端口。无论如何,这是npm的DNS解析问题。请使用此选项。这对我有用。