更新到 nodejs 8 后 Npm 抛出错误
Npm throw an error after update to nodejs 8
在我将我的 nodejs 更新到最新版本后,我在尝试 运行 npm install
安装软件包时总是出错:
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'
我的 Internet 连接没有任何问题,我禁用了到 https: https://registry.npmjs.org 的路由并将其替换为 http - 第一次安装有效,但在开始后立即无法再次工作。
节点版本8.2.1
npm 版本 5.3.0
感谢您的帮助。
您可能需要检查您的 NPM 代理设置并可能将其删除。
npm config get proxy
npm config rm proxy
npm config rm https-proxy
人们可能认为全新安装的 NodeJS+NPM 不会配置代理。奇怪的是,我的确实定义了一个代理,指向一个 IP 和端口 3128。删除代理就成功了。
如果它对任何人都有帮助:唯一对我有用的解决方案是 ping 注册表以查找 IP。而且我有 IP 的事实意味着我没有被阻止
ping registry.npmjs.org
64 bytes from registry.npmjs.org (151.101.60.162): icmp_seq=1 ttl=52 time=87.3 ms
在我的主机文件中设置此主机的 IP(我在 centos /etc/hosts/):
151.101.60.162 registry.npmjs.org
我几乎可以肯定这是 NPM 中的一些小故障
我尝试了第一个解决方案,ping registry.npmjs.org 并将其添加到主机文件,但不起作用,我尝试了第二种方法:
npm config get proxy
npm config rm proxy
npm config rm https-proxy
这对我有用。
使用 "npm config get proxy" 我有一个端口 8080 的值现在它是空的。
我不知道这个值是从哪里来的。
在您的命令提示符中设置代理,如下所示。
npm config set proxy http://1X.XX.X.40:80
问题解决了。
在我将我的 nodejs 更新到最新版本后,我在尝试 运行 npm install
安装软件包时总是出错:
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'
我的 Internet 连接没有任何问题,我禁用了到 https: https://registry.npmjs.org 的路由并将其替换为 http - 第一次安装有效,但在开始后立即无法再次工作。
节点版本8.2.1
npm 版本 5.3.0
感谢您的帮助。
您可能需要检查您的 NPM 代理设置并可能将其删除。
npm config get proxy
npm config rm proxy
npm config rm https-proxy
人们可能认为全新安装的 NodeJS+NPM 不会配置代理。奇怪的是,我的确实定义了一个代理,指向一个 IP 和端口 3128。删除代理就成功了。
如果它对任何人都有帮助:唯一对我有用的解决方案是 ping 注册表以查找 IP。而且我有 IP 的事实意味着我没有被阻止
ping registry.npmjs.org
64 bytes from registry.npmjs.org (151.101.60.162): icmp_seq=1 ttl=52 time=87.3 ms
在我的主机文件中设置此主机的 IP(我在 centos /etc/hosts/):
151.101.60.162 registry.npmjs.org
我几乎可以肯定这是 NPM 中的一些小故障
我尝试了第一个解决方案,ping registry.npmjs.org 并将其添加到主机文件,但不起作用,我尝试了第二种方法:
npm config get proxy
npm config rm proxy
npm config rm https-proxy
这对我有用。 使用 "npm config get proxy" 我有一个端口 8080 的值现在它是空的。
我不知道这个值是从哪里来的。
在您的命令提示符中设置代理,如下所示。
npm config set proxy http://1X.XX.X.40:80
问题解决了。