我正确地为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 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或谷歌我已经找到有关此问题的信息,但所有关于代理配置的说法,但我不使用任何代理,因为我的板直接连接到有线电视的路由器,仍然连接到互联网。
在示例中,我可以正确ping主机:registry.npmjs.org
但是npm无法识别。
我也试过没有成功设置npm config:
npm config set strict-ssl false
npm config set registry http://registry.npmjs.org/
我希望能解决这个问题。
答案 0 :(得分:0)
我遇到了同样的问题,这是我的主机文件有条目
的问题185.31.17.162 registry.npmjs.org
一旦我删除了它,一切都很完美。这是我在2016年10月的DYN攻击中添加的一种解决方法。