linux - npm “error network getaddrinfo ENOTFOUND registry.npmjs.org”

标签 linux node.js npm arm

我已经正确地为 ARM cortex-A5 交叉编译了 node.js (v0.12.8) 和 npm (v2.14.9)。如果我成功运行 node.js 示例 hello world。

但是当我尝试通过 npm 安装任何包时,结果总是:

npm 错误! network getaddrinfo ENOTFOUND registry.npmjs.org

遵循完整的调试信息:

root@myboard:/# npm install -g forever -d
npm info it worked if it ends with ok
npm info using npm@2.14.9
npm info using node@v0.12.8
npm info attempt registry request try #1 at 19:05:56
npm http request GET http://registry.npmjs.org/forever
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org
npm info attempt registry request try #2 at 19:06:06
npm http request GET http://registry.npmjs.org/forever
npm info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org
npm info attempt registry request try #3 at 19:07:06
npm http request GET http://registry.npmjs.org/forever
npm ERR! Linux 3.18.23
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "forever" "-d"
npm ERR! node v0.12.8
npm ERR! npm  v2.14.9
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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'

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log
root@myboard:/#
root@myboard:/# ping registry.npmjs.org
PING registry.npmjs.org (185.31.17.162): 56 data bytes
64 bytes from 185.31.17.162: seq=0 ttl=54 time=64.314 ms
64 bytes from 185.31.17.162: seq=1 ttl=54 time=64.403 ms
64 bytes from 185.31.17.162: seq=2 ttl=56 time=64.846 ms
^C
--- registry.npmjs.org ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 64.314/64.521/64.846 ms
root@myboard:/#

在 stackoverflow 或 google 中,我找到了有关此问题的信息,但都提到了代理配置,但我没有使用任何代理,因为 myboard 使用电缆直接连接到路由器并且仍然连接到互联网。 例如,我可以正确 ping 主机:registry.npmjs.org 但 npm 无法识别。

我也试过设置 npm config 没有成功:

npm 配置设置 strict-ssl false

npm 配置集注册表 http://registry.npmjs.org/

我希望存在关于这个问题的任何解决方案。

最佳答案

我遇到了同样的问题,这是我的主机文件有条目的问题

185.31.17.162    registry.npmjs.org

一旦我删除了它,一切就完美了。这是我在 2016 年 10 月 DYN 攻击期间添加的解决方法。

关于linux - npm “error network getaddrinfo ENOTFOUND registry.npmjs.org”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34274886/

相关文章:

linux - 使用 MPI 应用程序运行 perf

linux - Ubuntu 18中的服务崩溃问题

javascript - 是否有可能在 Q.All 中一次返回所有 "failures"

javascript - 组合数组中相似的对象

node.js - 请求(HTTP 请求客户端)是否同步?

javascript - 当有人安装我的 npm 模块时,如何告诉 npm 不要安装任何依赖项?

c++ - 异步 IO 中实际发生的情况

Python-导入json返回模块未找到

node.js - npm install mongoose 导致 gyp 和 kerberos 错误(未找到 gssapi/gssapi.h 文件)

javascript - CSS 不适用于 Webpacked 模块