Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm throw an error after update to nodejs 8

After I update my nodejs to the latest version I always get error when trying to run npm install to install packages:

npm WARN registry Using stale data from http://registry.npmjs.org/ because the host is inaccessible -- are you offline?
npm WARN registry Using stale package data from http://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to http://registry.npmjs.org/escope failed,      reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

I don't have any issues with my internet connection and I disable the route to https: https://registry.npmjs.org and replace it with http - the first install worked and right after start not working again.

node version 8.2.1

npm version 5.3.0

Thanks for any help.

like image 501
Adidi Avatar asked Jul 24 '17 21:07

Adidi


2 Answers

If it's helps to anyone: The only solution that works for me is to ping registry to find the IP. and the fact I have got the IP means I am not blocked

ping registry.npmjs.org

64 bytes from registry.npmjs.org (151.101.60.162): icmp_seq=1 ttl=52 time=87.3 ms

Set the IP to this host on my hosts file (Im in centos /etc/hosts/):

151.101.60.162 registry.npmjs.org

I am almost sure it's some glitch in NPM

like image 165
Adidi Avatar answered Oct 14 '22 06:10

Adidi


You may want to check your NPM proxy settings and perhaps remove it.

npm config get proxy
npm config rm proxy
npm config rm https-proxy

One might expect a fresh install of NodeJS+NPM would not have a proxy configured. Strangely enough, mine did come with a proxy defined, pointing to an IP and port 3128. Removing the proxy did the trick.

like image 14
Jijo Paulose Avatar answered Oct 14 '22 05:10

Jijo Paulose