231

Bower install fails with 502 - Bad Gateway when downloading bower packages.

For example bower install for ember library gives following response in command line.

EINVRES Request to https://bower.herokuapp.com/packages/ember failed with 502

When http://bower.herokuapp.com/ is accessed directly from URL it gives the following message.

This Bower version is deprecated. Please update it: npm install -g bower. The new registry address is https://registry.bower.io

Nithin Baby
  • 7,236
  • 4
  • 16
  • 24

5 Answers5

453

Bower is deprecating their registry hosted with Heroku. http://bower.herokuapp.com/ Will not be accessible anymore or it might be down intermittently, therefore, forcing users to a new registry.

Users working on old bower versions can update the .bowerrc file with the following data.

{
  "registry": "https://registry.bower.io"
}

.bowerrc file can be located at the same folder where bower.json and bower_components folder is located. If it is not present already, you can make one.

For references check the below links

Anmol
  • 33
  • 5
Nithin Baby
  • 7,236
  • 4
  • 16
  • 24
  • 47
    Just to be clear for those who don't read closely: updating bower is the preferred solution: `npm install -g bower` – marcovtwout Jun 25 '18 at 12:40
  • 10
    It's weird that they deprecated this registry nine months ago, and I don't recall ever seeing any warnings when I ran bower until today, when things started 502'ing – EricRRichards Jun 25 '18 at 15:34
  • 19
    Upgrading bower to latest (1.8.4) didn't fix it for me. However, adding a .bowerrc worked like a charm (at least until we're able to migrate away). – Brian Jun 25 '18 at 20:15
  • 2
    Same problem for me like @Brian described. This saved my day. Guess its time to update this old project to yarn eventually -.- – nex Jun 28 '18 at 16:25
  • 2
    This is the better solution because updating the version of bower is not always possible in a project with multiple dependencies. – Thembelani M Jul 03 '18 at 07:43
  • We've been seeing that on our Mac dev machines, it continues to work in 1.8.4 but stopped working on our linux based build servers. Potentially related to a difference in behavior people are seeing? – Richard Collette Jul 23 '18 at 20:29
  • Updating bower does not help at all in this most cases for old bower versions and the file .bowerrc does as well not exist. The solution from Nithin is the optimal solution. Just create a new empty file and add the 3 lines from this solution and everything works again perfectly. – Oliver Aug 13 '18 at 00:26
  • also noted that if you using Rails or .bowerrc already in your sub-directory. you have to update them otherwise ~/.bowerrc will overwrite its. – Jirapong Nov 21 '18 at 11:22
  • For me the upgrade to latest did not work instantly on all computers. Perhaps Bower is using a form of caching for the registry url? I applied the .bowerrc solution once as a workaround. – marcovtwout Dec 03 '18 at 09:09
  • for windows users you have to name the file ".bowerrc." see also: https://stackoverflow.com/questions/20202202/how-do-i-name-the-bowerrc-file – TruthOf42 Mar 22 '19 at 13:51
  • This solution solved the problem when I compile the tez-ui module. – Shuai Liu Mar 25 '19 at 02:03
56

Simplest solution is to just upgrade bower to latest version

If installed via NPM:

npm i -g bower
tkarls
  • 2,783
  • 1
  • 24
  • 26
  • 16
    Didn't work. I ended up at latest Bower (1.8.4) but problem persisted. See other suggestion about .bowerrc – Brian Jun 25 '18 at 20:16
  • That is pretty strange since I did the exact same thing yesterday and got the same version 1.8.4 which did resolve the problem. And is also what bower themselves recommend. Perhaps something else is a problem in your setup so you're not running the bower that you think you are – tkarls Jun 26 '18 at 13:17
  • 1
    I am also running at 1.8.4 and am still getting the message. The workaround above works, but it would be nice to get it fixed so the default points to the new registry. – DavidA Jun 26 '18 at 16:06
  • upgrading bower in a large complex and aged project is far far far from the simplest solution.. – keen Jul 31 '18 at 23:15
  • @Brian: if you Windows, you must run command with administrator! – Le Hoai Duc Sep 07 '18 at 08:35
  • 1
    If you are working on a project that someone else set up, then bower may be installed locally, in which case updating the global version will not help. – benjifisher Sep 24 '18 at 22:16
8

When using asp.net core then should change something like this. bowerrc.json you can find inside project folder.

  {
     "registry": "https://registry.bower.io",
     "directory": "wwwroot/lib"
  }
Nayas Subramanian
  • 1,901
  • 16
  • 24
1

If you use windows to install npm, You must run "Node.js command prompt" with administrator and run this command: npm i -g bower. I tried and worked :)

Le Hoai Duc
  • 69
  • 1
  • 2
0

echo '{"registry": "https://components.bower.io","directory": "wwwroot/lib"}' > .bowerrc

territorial
  • 136
  • 1
  • 5