[英]npm install behind one proxy but got Http Error=407 (Forefront TMG requires authorization)
我的筆記本電腦使用MacOS,並且已經在網絡偏好設置中設置了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?
最后找出解決方案 :
不要使用純文本密碼 (在“ Password
行的開頭添加一個#
,例如將“ Password XXX
更改為“ #
Password XXX
#Password XXX
)
請改用PassLM , PassNT , PassNTLMv2 (似乎哈希值將再次阻止身份驗證握手機制,這意味着您代表使用Windows用戶帳戶登錄的應用程序)。
默認的cntlm配置文件已經介紹了如何生成它們的步驟。
我的步驟如下:
執行cntlm -H -d your_domain -u your_username
然后提示輸入密碼, 輸入密碼,然后按Enter :
輸出將如下所示:
Password:
PassLM F5314AF8A2DB16BDB7EE9FA6CFC5BC9A
PassNT 4EC02E0D65F8F0C1A9386C69CB6A2555
PassNTLMv2 28B089518C6573274C6B9D83D0EB8651
將上面的哈希值粘貼到配置文件中的相關字段。
保存然后重新啟動cntlm ,它可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.