NPM 安装无法从需要身份验证的代理后面进行 - 已尝试配置设置代理=

NPM 安装无法从需要身份验证的代理后面进行 - 已尝试配置设置代理=

这是在运行 ActiveDirectory 的网络中的 Windows 上运行 Nodejs 包管理器 (NPM) 时出现的问题 - 而问题似乎是因为我使用了公司代理。

我希望 NPM INSTALL 能够工作......

我们有一个使用 WPAD 和身份验证的代理。

从 Wpad.dat 中我获得了代理的 FQDN 和端口(见下文)。

我用过

NPM CONFIG SET PROXY = http://<domain>%5C<username>:<passwordwith#>@ddcrpit311v1.corp.<company>.global:8080

设置代理信息(包括用户名和密码)

NPM CONFIG SET HTTPS-PROXY = <as above>

我已经设定

NPM CONFIG SET registry = http://registry.npmjs.org/

这样我就不用担心 SSL 了(以防万一)

NPM CONFIG SET strict-ssl = false

我仍然收到错误:

>npm install sax-js
npm http GET http://registry.npmjs.org/sax-js
npm http GET http://registry.npmjs.org/sax-js
npm http GET http://registry.npmjs.org/sax-js
npm ERR! network getaddrinfo ENOTFOUND
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! System Windows_NT 5.1.2600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sax-js"
npm ERR! cwd C:\Documents and Settings\morsli00
npm ERR! node -v v0.10.10
npm ERR! npm -v 1.2.25
npm ERR! syscall getaddrinfo
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Documents and Settings\morsli00\npm-debug.log
npm ERR! not ok code 0

从日志中可以看出以下内容很重要:

20 verbose url resolving [ 'http://registry.npmjs.org/', './sax-js' ]
21 verbose url resolved http://registry.npmjs.org/sax-js
22 info trying registry request attempt 1 at 16:00:20
23 http GET http://registry.npmjs.org/sax-js
24 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
25 info trying registry request attempt 2 at 16:00:31
26 http GET http://registry.npmjs.org/sax-js
27 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
28 info trying registry request attempt 3 at 16:01:31
29 http GET http://registry.npmjs.org/sax-js
30 silly lockFile 4d5ae745-sax-js sax-js@
31 silly lockFile 4d5ae745-sax-js sax-js@
32 error network getaddrinfo ENOTFOUND
32 error network This is most likely not a problem with npm itself
32 error network and is related to network connectivity.
32 error network In most cases you are behind a proxy or have bad network settings.
32 error network
32 error network If you are behind a proxy, please make sure that the
32 error network 'proxy' config is set properly.  See: 'npm help config'
33 error System Windows_NT 5.1.2600
34 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "sax-js"
35 error cwd C:\Documents and Settings\morsli00
36 error node -v v0.10.10
37 error npm -v 1.2.25
38 error syscall getaddrinfo
39 error code ENOTFOUND
40 error errno ENOTFOUND
41 verbose exit [ 1, true ]

我尝试不使用 %5C 以及 /\,结果都相同。

我尝试配置 fiddler2 作为反向代理,并将代理地址设置为 localhost:8888,并配置 fiddler 连接到代理 - 但随后我也遇到了错误。

有没有一个简单的代理程序可以设置为反向代理,以便对我进行身份验证? Node 中有什么可以尝试的吗?

欢迎任何想法!

答案1

尝试在命令中添加双引号:

NPM CONFIG SET PROXY = "http://<domain>%5C<username>:<passwordwith#>@ddcrpit311v1.corp.<company>.global:8080"

和 :

NPM CONFIG SET HTTPS-PROXY = "http://<domain>%5C<username>:<passwordwith#>@ddcrpit311v1.corp.<company>.global:8080"

这对我很有用。;)

答案2

这是我的最终工作 .npmrc 文件

proxy=http://DOMAIN%5Cusername:password@proxyaddress:8080/ https-proxy=http://DOMAIN%5Cusername:password@proxyaddress:8080/ loglevel=verbose

答案3

在 Ubuntu 16.04 上对我有用


npm config 设置代理'http://:'

npm config 设置 https-proxy 'http://:'

相关内容