怎么在NTLM的代理的后面,使用npm安装node.js的扩展

如何在NTLM的代理的后面,使用npm安装node.js的扩展

今天有些时间学习新知识了。

另一个项目,实现了第一阶段的联调的通过。静下心来几天,庆祝一下这个节点。

顺便学习node.js


一个重要的要解决的问题,就是如何在NTLM后面,使用npm。

事实上,这是一个古老的,linux体系的一个大bug: 设置代理时,不能使用域,只能使用有主机名的(好象iMac解决了)。


今天找了一上午,终于找到一个可能的办法:

http://*.com/questions/18569054/npm-behind-ntlm-proxy


原理就是,先在本地搭一下代理,这样一来,代理字串就变面这样了:

http://localhost:53128

而不是http://myadname\\proxyhostname:port的样子了。

*******************************************

虽然说,网上有许多文章,说可以用这样的方式

proxy = http://domain\\username:password@ip:port

但事实证明,不论是如何设置,都是不成的。

如下的都不成:


npm config set proxy http://bj\\haoyujie:pwd@myproxyhostname:8080
npm config set https-proxy http://bj\\haoyujie:pwd@myproxyhostname:8080

npm --proxy=http://bj/haoyujie:pwd@myproxyhostname:8080 --proxy-https=http://bj/haoyujie:mypwd@myproxyhostname: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_USERNAME
Domain      YOUR_DOMAIN
Proxy       YOUR_PROXY_IP:PORT
Listen      53128

3. Open console, and type these commands to generate password hashes.

> cd c:\the_install_directory_of_cntlm
> cntlm -H
Password: ...type proxy password here...
PassLM          D6888AC8AE0EEE294D954420463215AE
PassNT          0E1FAED265D32EBBFB15F410D27994B2
PassNTLMv2      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://*.com/questions/18569054/npm-behind-ntlm-proxy

*********************************

才看到,原来这哥们使用的是我的最爱:winxp sp3

早知道我也用XP啊。一会装个XP在vmWare上。

我是在window 7 x64上试成功的。

**************************************

另外,不要尝试改:

c:\users\youname\.npmrc

没用。

*******************************

1楼haoyujie昨天 15:25
才看到,这哥们是用的我最爱的winXP sp3,我现在用的是WIN7 x64。以后也装个XP在虚机上来学习NODE.JS