Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 Internal Server Error: npm@latest

Tags:

npm

I have a problem with npm I can't get any package. For example running :

npm install -g npm@latest

gives :

npm ERR! code E500 npm ERR! 
500 Internal Server Error: npm@latest

If I try to access https://registry.npmjs.org/ I get :

Fastly error: unknown domain. 
Please check that this domain has been added to a service.

I looked into my /etc/hosts and nothing wrong there, any ideas ?

---------------- INFOS -----------

    NodeJS : v9.2.0
    npm    : 6.0.1
    OS     : Ubuntu 16.04.4 LTS
like image 429
Ostn Avatar asked Jun 06 '18 17:06

Ostn


2 Answers

Below step resolve my npm registry issue. I hope same will be work for you.

  1. Try to set npm registry using : npm config set registry https://registry.npmjs.org/
  2. Check result of curl https://registry.npmjs.org/
  3. Clear the cache: npm cache clean --force
  4. Try to run npm install
like image 54
Sagar Avatar answered Sep 21 '22 14:09

Sagar


From corporate network sometimes you won't be able to properly resolve registry.npmjs.org. To workaround the problem do the following.

dig registry.npmjs.org @1.1.1.1

Take any of the ip in the output and add to /etc/hosts

104.16.16.35 registry.npmjs.org

You should be good to go now.

like image 27
Atul Soman Avatar answered Sep 21 '22 14:09

Atul Soman