標籤:node.js npm ntlm proxy
今天有些時間學習新知識了。
另一個項目,實現了第一階段的聯調的通過。靜下心來幾天,慶祝一下這個節點。
順便學習node.js
一個重要的要解決的問題,就是如何在NTLM後面,使用npm。
事實上,這是一個古老的,linux體系的一個大bug: 設定代理時,不能使用域,只能使用有主機名稱的(好象iMac解決了)。
今天找了一上午,終於找到一個可能的辦法:
http://stackoverflow.com/questions/18569054/npm-behind-ntlm-proxy
原理就是,先在本地搭一下代理,這樣一來,代理字串就變面這樣了:
http://localhost:53128
而不是http://myadname\\proxyhostname:port的樣子了。
*******************************************
雖然說,網上有許多文章,說可以用這樣的方式
proxy = http://domain\\username:[email protected]:port
但事實證明,不論是如何設定,都是不成的。
如下的都不成:
npm config set proxy http://bj\\haoyujie:[email protected]:8080
npm config set https-proxy http://bj\\haoyujie:[email protected]:8080
npm --proxy=http://bj/haoyujie:[email protected]:8080 --proxy-https=http://bj/haoyujie:[email protected]:8080 --registry=http://registry.npmjs.org/ install mime
**********************************************
問:
Is it possible to run npm install behind an HTTP proxy, which uses NTLM authentication? If yes, how can I set the server‘s address and port, the username, and the password?
---------------
ANS:
I solved it this way (OS: Windows XP SP3):
1. Download CNTLM installer and run it.
2. Find and fill in these fields in cntlm.ini. Do not fill in thePassword field, it‘s never a good idea to store unencrypted passwords in text files.
Username YOUR_USERNAMEDomain YOUR_DOMAINProxy YOUR_PROXY_IP:PORTListen 53128
3. Open console, and type these commands to generate password hashes.
> cd c:\the_install_directory_of_cntlm> cntlm -HPassword: ...type proxy password here...PassLM D6888AC8AE0EEE294D954420463215AEPassNT 0E1FAED265D32EBBFB15F410D27994B2PassNTLMv2 91E810C86B3FD1BD14342F945ED42CD6
4. Copy the above three lines into cntlm.ini, under the Domain field‘s line. Once more, do not fill in the Password field. Save cntlm.ini.
5. Open the Service Manager (from command line: services.msc), and start the service called "CNTLM Authentication Proxy".
6. In the console, type these lines:
> npm config set proxy http://localhost:53128> npm config set https-proxy https://localhost:53128> npm config set registry "http://registry.npmjs.org/"
7. Now npm view, npm install etc. should work. Example:
> npm view qunit...nice answer, no errors :)
********************************
Ooo Yeath .
反正我的是可以用了。
感謝
http://stackoverflow.com/questions/18569054/npm-behind-ntlm-proxy
*********************************
才看到,原來這哥們使用的是我的最愛:winxp sp3
早知道我也用XP啊。一會裝個XP在vmWare上。
我是在window 7 x64上試成功的。
**************************************
另外,不要嘗試改:
c:\users\youname\.npmrc
沒用。
*******************************