Configuring npm proxy details so that bower install work through a proxy

Trying to connect to npm while on a proxy?

When connected to a proxy and downloading bower depencies via the console/command line the following settings need to be set.

Update npm configs

npm config set proxy http://[username]:password]@[url]:[port]

npm config set https-proxy http://[username]:password]@[url]:[port]

Now you should be able to install dependencies through the proxy using npm

Example npm commands

bower install
npm install

 

Configuring github to work through a proxy

Edit the .gitconfig file on Windows to work with a proxy

Open your .gitconfig file. You can find this file in your C:/Users/[your user] folder.

Edit the .gitconfig file on Ubuntu/Linux to work with a proxy

Open your .gitconfig file. You can find this file in your home ~/ folder.

You can type in the command line:

sudo nano ~/.gitconfig

Edit the .gitconfig file

Insert the following lines:

[http]
proxy = http://username:password@proxyurl:port
[https]
proxy = http://username:password@proxyurl:port
sslVerify = false

Username would be your proxy username.

Password would be your proxy password.

Proxyurl would be the proxy url.

Port would be the proxy port.

View your git settings

You can check your git settings in the command line by running the following:

git config -l

 

Configuring a proxy on windows and linux

I have a daily battle with a proxy. Each day I think, “today this proxy will be tamed”. Only to have the proxy stop working and I have to start figuring it out from scratch.

Below is what I go through each time I experience problems with proxy connection.

Connecting to a proxy via command line:

Windows

Configure your windows environment to work through a proxy

Environment variables

One way is to update your environment variables.

Open a command console, and in it add these two settings:

set http_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”
set https_proxy=”’http://proxyUsername:proxyPassword@proxyUrl:port”

View environment variables

To view your system settings enter in your command console:

set

Using “set” is more like a “cache” setting, it will go away when you close the command console, or restart your computer. To set it permanently, either manually add it to your environment variables. Or use setx.

setx /M http_proxy “http://proxyUsername:proxyPassword@proxyUrl:port”
setx /M https_proxy “http://proxyUsername:proxyPassword@proxyUrl:port”

A note on the value ”http://proxyUsername:proxyPassword@proxyUrl:port”

This format can be:

  • ”http://proxyUsername:proxyPassword@proxyUrl:port”
  • ”http://proxyUrl:port”

Another note: ping will not work with a proxy. (Well for now I haven’t found a way for it to work yet.) From the research I have done to date, ping works at a different level to the proxy. So just a head’s up, if you use ping to test if your proxy settings now allow internet access, you will be going in circles.

What should work is if you use a tool like vagrant for example and you need to download a box.

If this doesn’t work, and you use a tool that needs internet acces through the command line and it still cannot connect to the internet. Make double-triple sure your proxy details are 100% correct. Make sure you are connected to the internet.

And try the below:

LAN Settings

Setting the proxy on the lan settings. I have found two ways of setting this, one way is through a web browser like Chrome. And the other is through the control panel.

Using chrome

Go to Settings.
Show advanced settings.
In the Network section click “Change proxy settings”.
In the window that opens up click on “LAN settings”.
Select “Use a proxy server for your LAN…”
Add the proxy address, add the proxy port.

Additional notes on using windows for proxy

  • Often something doesn’t work because you need to open a new console window for to take effect (eg changing environment variables).
  • Often something doesn’t work because you nee the entire system to be restarted (this is always my last go to, if all else fails, restart).

Proxy is still not working on windows

If you have done all of the above and you still do not have internet acces through the proxy, you need to check if your proxy itself is not blocking the access.

Setting up proxy details on Linux

This is still a work in progress, below is what I’ve figured out so far:
To set the system variables on linux:

export http_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”
export https_proxy=”http://proxyUsername:proxyPassword@proxyUrl:port”