59

is there a way to configure bower not only to use a proxy but ignore the proxy configuration for some domains?

I have the problem, that I will run an internal bower registry for our own developed components. For that repository I would like to ignore the proxy configuration.

Johann Sonntagbauer
  • 1,294
  • 1
  • 10
  • 20

11 Answers11

76

Edit your .bowerrc file ( should be next to your bower.json file ) and add the wanted proxy configuration

"proxy":"http://<host>:<port>",
"https-proxy":"http://<host>:<port>"
Itsik Avidan
  • 1,681
  • 1
  • 12
  • 7
  • where are either of these files in ubuntu? – KillerSnail Apr 16 '14 at 04:05
  • 5
    If the file is not present, create it in the same folder as bower.json. Also, it should be valid JSON, so wrap it with {}. See @eastolfi's answer. – Ali Cheaito Apr 23 '14 at 15:37
  • 1
    You can also use this in your home folder as a global setting: in ~/ – Eric Steinborn Apr 28 '14 at 18:14
  • 2
    This should be the selected answer, as per [the docs](http://bower.io/docs/config/) this is the correct way to configure Bower for these cases. –  Sep 16 '14 at 12:57
  • This should be selected as answer. worked like a charm – Vishnudev K May 21 '15 at 13:59
  • Upvoted - I was already using CNTLM (as the accepted answer suggests), however I still had to create the `.bowerrc` to tell bower which port the proxy was listening on, thanks :) – danwild May 26 '15 at 23:08
  • Watch out for when this gets checked-into Git and runs on your build server which doesn't use the proxy. – Luke Puplett Dec 11 '15 at 12:19
55

For info, in your .bowerrc file you can add a no-proxy attribute. I don't know since when it is supported but it works on bower 1.7.4

.bowerrc :

{
  "directory": "bower_components", 
  "proxy": "http://yourProxy:yourPort",
  "https-proxy":"http://yourProxy:yourPort",
  "no-proxy":"myserver.mydomain.com"
}

.bowerrc should be located in the root folder of your Javascript project, the folder in which you launch the bower command. You can also have it in your home folder (~/.bowerrc).

jpyams
  • 4,030
  • 9
  • 41
  • 66
loicmathieu
  • 5,181
  • 26
  • 31
27

I had ETIMEDOUT error, and after putting

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

just worked. I don't know if you have something wrong in the .bowerrc or ECONNRESET can't be solved with this, but I hope this help you ;)

momo
  • 3,404
  • 6
  • 37
  • 66
eastolfi
  • 379
  • 3
  • 4
14

I struggled with this from behind a proxy so I thought I should post what I did. Below one is worked for me.

-> "export HTTPS_PROXY=(yourproxy)"

Vara
  • 149
  • 1
  • 2
8

The key for me was adding an extra line, "strict-ssl": false

Create .bowerrc on root folder, and add the following,

{
  "directory": "bower_components", // If you change this, your folder named will change within dependecies. EX) Vendors instead of bower_components.
  "proxy": "http://yourProxy:yourPort",
  "https-proxy":"http://yourProxy:yourPort",
  "strict-ssl": false 
}

Best of luck for the people still stuck on this.

misterzik
  • 1,740
  • 1
  • 16
  • 20
7

There is no way to configure an exclusion to the proxy settings, but a colleague of mine had an create solution for that particular problem. He installed a local proxy server called cntlm. That server supports ntlm authentication and exclusions to the general proxy settings. A perfect match.

tomcyjohn
  • 145
  • 2
  • 4
Johann Sonntagbauer
  • 1,294
  • 1
  • 10
  • 20
4

Inside your local project open the .bowerrc that contains:

{
   "directory": "bower_components"
 }

and add the following code-line:

{
   "directory": "bower_components",
  "proxy": "http://yourProxy:yourPort",
  "https-proxy":"http://yourProxy:yourPort"
}

bower version: 1.7.1

Cheers

user278049
  • 113
  • 1
  • 4
2

Add the below entry to your .bowerrc:

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

Also if your password contains any special character URL-encode it Eg: replace the @ character with %40

m00am
  • 5,910
  • 11
  • 53
  • 69
Vishnu V R
  • 111
  • 1
1

Are you using Windows? Just set the environment variable http_proxy...

set http_proxy=http://your-proxy-address.com:port

... and bower will pick this up. Rather than dealing with a unique config file in your project folder - right? (side-note: when-the-F! will windows allow us to create a .file using explorer? c'mon windows!)

Adam Cox
  • 3,341
  • 1
  • 36
  • 46
0

create .bowerrc file in you home directory and adding this to the file worked for me

{

 "directory": "bower_components",
 "proxy": "http://youProxy:yourPort",
  "https-proxy":"http://yourProxy:yourPort"
}
-6

add in .bowerrc

{SET HTTP_PROXY= http://HOST:PORT,SET HTTPS_PROXY=http://HOST:PORT}

In NPM, you must to execute in console this:

npm --proxy http://Host:Port install
Cristian Agudelo
  • 628
  • 1
  • 7
  • 10