npm ERR!代码E407需要代理身份验证

时间:2019-03-18 13:06:06

标签: npm proxy-authentication

当我尝试运行npm命令时,出现错误。

错误日志如下:

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   'install',
1 verbose cli   'graph' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose npm-session 7743923ae4798761
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 407 https://registry.npmjs.org/graph 7681ms
8 silly fetchPackageMetaData error for graph@latest 407 Proxy Authentication Required: graph@latest
9 timing stage:rollbackFailedOptional Completed in 9ms
10 timing stage:runTopLevelLifecycles Completed in 8056ms
11 verbose stack Error: 407 Proxy Authentication Required: graph@latest
11 verbose stack     at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
11 verbose stack     at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
11 verbose stack     at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
11 verbose stack     at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
11 verbose stack     at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
11 verbose stack     at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
11 verbose stack     at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
11 verbose stack     at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
11 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
11 verbose stack     at runCallback (timers.js:705:18)
11 verbose stack     at tryOnImmediate (timers.js:676:5)
11 verbose stack     at processImmediate (timers.js:658:5)
12 verbose cwd C:\Windows\system32
13 verbose Windows_NT 6.1.7601
14 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "graph"
15 verbose node v10.15.3
16 verbose npm  v6.4.1
17 error code E407
18 error 407 Proxy Authentication Required: graph@latest
19 verbose exit [ 1, true ]

1 个答案:

答案 0 :(得分:0)

此错误最有可能是因为您位于代理之后,或者您所在的组织中正在使用代理。 要查找代理名称和端口,您需要执行以下步骤:
1.开始跑步
2.输入“ inetcpl.cpl”
3.转到连接选项卡
4.进入局域网设置 在那里您会找到地址和端口

在以下命令中获得“地址”和“端口”后,将其替换为“ proxy_name”和“ port”,然后将“用户名”替换为“您的用户名”,将“密码”替换为“您的密码”并运行

  

npm配置集代理http://username:password@proxy_name:port

     

npm配置设置为http-proxy http://username:password@proxy_name:port

然后运行npm。

这应该可行