【发布时间】:2018-10-15 23:11:53
【问题描述】:
我的笔记本使用的是MacOS,并且已经在Network Preferences里面设置了http(s)代理,但是在终端运行npm install时总是无法安装任何包,就弹出了错误407 Proxy Authentication Required.
所以我安装了 cntlm 并应用了正确的配置。
下面是测试,它似乎通过(返回 HTTP 代码 200):
cntlm -c /usr/local/etc/cntlm.conf -I -M http://registry.npmjs.org/vue
Password:
Config profile 1/4... OK (HTTP code: 200)
----------------------------[ Profile 0 ]------
Auth NTLMv2
PassNTLMv2 28B089518C6573274C6B9D83D0XXXXXX
当我运行npm i vue-cli -g时,cntlm确实收到了如下请求:
cntlm -c /usr/local/etc/cntlm.conf -f
Oct 15 15:12:29 cntlm[17646] <Info>: Cntlm ready, staying in the foreground
Oct 15 15:12:38 cntlm[17646] <Info>: Using proxy company-proxy:80
Oct 15 15:12:38 cntlm[17646] <Debug>: 127.0.0.1 GET http://registry.npmjs.org/nexe
但是 nodejs 抛出了以下异常:
npm i vue-cli -g
npm ERR! code E407
npm ERR! 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ): vue-cli@latest
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/****/.npm/_logs/2018-10-15T23_13_47_019Z-debug.log
这让我很困惑:因为测试通过了,但是为什么 cntlm 仍然无法连接到 npmjs.org?
【问题讨论】: