Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM install failing with 502 error

This is a rather obscure issue. I have an Angular app that will be running through Codeship for CI. However, when it comes time to run npm install on the Codeship box, npm gives back

-npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 502
\npm ERR! fetch failed https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz
npm ERR! Linux 4.2.0-38-generic
npm ERR! argv "/home/rof/.nvm/versions/node/v4.1.1/bin/node" "/home/rof/.nvm/versions/node/v4.1.1/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4

npm ERR! fetch failed with status code 502

This was quite strange, since the npm install worked just fine on my box. My first instinct was that it had to be an issue with the NPM repository, so I grabbed the url for the package(https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz) and threw it into a new Chrome tab. Sure enough, the archive downloaded almost instantly. I was confused by this, so I tried the Codeship build again, but got the same results. I decided to SSH into the Codeship box to see if I could access it. I ran

curl https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-2.4.1.tgz

and as I expected I got the 502 error. However, when I ran the same command from the terminal on my machine, I got the same result, even though the npm install ran perfectly for me. I wasn't able to find anyone else having this type of an issue, and a 502 seems like a very rare code for the NPM registry to be returning. Any ideas?

like image 810
Chandler Freeman Avatar asked Jul 06 '16 07:07

Chandler Freeman


People also ask

Why npm install is failing?

The error in NPM, 'error package install failed, see above', can occur when the user creates a new project in Angular using Node. js using VS code. This means that NPM is corrupted in your system, and must reinstall NPM.

What causes a 502 Bad Gateway?

What causes a 502 Bad Gateway error? Server overload: An overloaded server is one of the most common causes of a 502 error. This is where the server has reached its memory capacity, often activated by an unusually high number of visitors trying to access the same website.


1 Answers

This is a problem with the registry.npmjs.org in some regions.

Here is issue: https://github.com/npm/npm/issues/13284

like image 77
Andrey Romashin Avatar answered Oct 01 '22 05:10

Andrey Romashin