How to use NPM Behind a SOCKS Proxy

James Jeffery
1 min readNov 10, 2016

--

If you’re behind a SOCKS proxy and want to use npm to install node packages you’re sadly out of luck. npm doesn’t support the use of SOCKS proxies, but it does support HTTP proxies.

In this guide I will show you how to turn your SOCKS proxy into a HTTP proxy to use npm. This has been tested on Ubuntu Xenial Xerus but should work fine on other Linux distributions.

First we need to install polipo to create the HTTP proxy. Head over to the terminal and install it:

sudo apt-get install polipo

Once installed open the polipo configuration file: vim /etc/polipo/config and add the following lines:

socksParentProxy = “127.0.0.1:1337”
socksProxyType = socks5
proxyAddress = “::0”
proxyPort = 8123

Restart polipo:

sudo service polipo restart

Next set up your SOCKS proxy. If you’re already using it you don’t need to perform this step.

ssh -fN -D1337 user@server

And finally set npm to use a HTTP proxy. Copy the lines below into the terminal:

npm config set proxy http://127.0.0.1:8123
npm config set https-proxy http://127.0.0.1:8123

Install something to test:

npm i webpack -g

If you did everything correctly you should now be able to use npm. If you found this guide useful please recommend :)

--

--