electronix384128
electronix384128

Reputation: 6733

npm Fails to Install over Socks5 Proxy

I am having trouble running npm install over a socks5 proxy.

Proxy is running locally, to tunnel http(s) over ssh to company intranet: ssh -vvv -D 5000 -N <SERVER_IP>

I have configured npm's proxy:

npm config set proxy socks5h://localhost:5000
npm config set https-proxy=socks5h://localhost:5000

I just get:

npm ERR! git clone https://<INTRANET>/repo fatal: unable to access 'https://<INTRANET>/repo/': Could not resolve host: <INTRANET>

Any ideas?

P.S.: git clone from the same git repo address works perfectly.

Upvotes: 3

Views: 10318

Answers (6)

user24526420
user24526420

Reputation: 21

npm config -L user set https-proxy=socks5h://127.0.0.1:9050 works for me behind tor. Check it with npm config -L user get https-proxy.

Upvotes: 2

Junior Tour
Junior Tour

Reputation: 640

Use v2rayN as client.

It will launch both socks5 and http proxy.

Then you can use its http proxy for npm proxy and socks5 for other proxy at same time.

// http for npm
npm config set http-proxy http://127.0.0.1:10809

// socks5 for git
git config --global http.proxy 'socks5://127.0.0.1:10808

v2raN UI Screen Shot

v2raN

Upvotes: 0

ramazan polat
ramazan polat

Reputation: 7900

For a workaround that works on both Linux and Windows, you can use http-proxy-to-socks.

$ npm install -g http-proxy-to-socks
$ hpts -s 127.0.0.1:1080 -p 8080

Now you have you http proxy at port 8080.

Upvotes: 1

SmilingSun
SmilingSun

Reputation: 515

You can use polipo to convert sock5 proxy to http proxy, and it's super convenient if you're under Linux.

You can reference this page for further detail:

Upvotes: 1

ohho
ohho

Reputation: 51951

Proxifier works for me. Simply add a proxy and npm install ...

proxifier.com/mac/

Upvotes: 1

electronix384128
electronix384128

Reputation: 6733

Ok, as of now, npm does not support socks proxy: https://github.com/npm/npm/issues/6204

I now use ProxyCap. http://www.proxycap.com Works great. It will manage the ssh tunnel + socks proxy and route all traffic automatically (also for npm) through it.

Upvotes: 1

Related Questions