npm“错误网络 getaddrinfo ENOTFOUNDregistry.npmjs.org”

问题描述 投票:0回答:2

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

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

npm ERR! 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 [email protected]
npm info using [email protected]
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 config set strict-ssl false

npm config set registry http://registry.npmjs.org/

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

linux node.js npm arm
2个回答
1
投票

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

185.31.17.162    registry.npmjs.org

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


0
投票

PS C:\Users\m-on

© www.soinside.com 2019 - 2024. All rights reserved.