Npm throws error after upgrading to nodejs 8

After I upgrade my nodejs to the latest version, I always get an 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 have no problems connecting to the Internet, and I will disable the route to https: https://registry.npmjs.org and replace it with http - the first installation worked and immediately after launch did not work again.

node version 8.2.1

npm version 5.3.0

Thanks for any help.

+7
source share
4 answers

If this helps anyone: the only solution that works for me is to ping the registry to find the IP address. and the fact that I have an IP facility is 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 address of this host in my hosts file (Im in centos / etc / hosts /):

151.101.60.162 registry.npmjs.org

I'm pretty sure this is a failure in NPM

+12
source

You might want to check the NPM proxy settings and possibly delete it.

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

You can expect that a new installation of NodeJS + NPM will not be configured on a proxy. Oddly enough, I really had a proxy server installed, pointing to IP and port 3128. Removing the proxy server did the trick.

+12
source

I am trying the first solution, ping registry.npmjs.org and adding it to the host file does not work, and I am trying the second way:

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

And it works for me. With "npm config get proxy" I had a value with port 8080, now it is zero.

I do not know where this value comes from.

0
source

Install the proxy as described below on the command line.

 npm config set proxy http://1X.XX.X.40:80 

This solved the problem.

0
source

Source: https://habr.com/ru/post/1270174/


All Articles