bower behind a proxy

benek picture benek · Feb 11, 2014 · Viewed 65.8k times · Source

bower install behind a proxy fails in timeout with the following settings (some set are useless...) :

git config --global http.proxy fr-proxy.example.com:3128
git config --global https.proxy fr-proxy.example.com:3128

export http_proxy=http://fr-proxy.example.com:3128
export https_proxy=http://fr-proxy.example.com:3128

npm config set proxy http://fr-proxy.example.com:3128
npm config set https-proxy http://fr-proxy.example.com:3128

npm config set registry http://registry.npmjs.org/

I have also tried an install/uninstall of bower and a bower clean cache.

Answer

rmic picture rmic · Apr 15, 2014

Edit your .bowerrc file and add the wanted proxy configuration:

{
    "proxy":"http://<host>:<port>",
    "https-proxy":"http://<host>:<port>"
}

If working behind an authenticated proxy, user and password should be included like this:

{
    "proxy":"http://<user>:<password>@<host>:<port>",
    "https-proxy":"http://<user>:<password>@<host>:<port>"
}

Usually, the .bowerrc is next to the bower.json. And if there is no .bowerrc file near the bower.json file, you can create one by yourself.