环境

阿里云 centos7

node v8.11.3

npm 5.6.0

错误

npm update

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443-LMLPHP

解决

ping registry.npmjs.org

发现https://registry.npmjs.org 网址ping不通

查看/etc/resolv.conf

vim /etc/resolv.conf

发现这个文件的dns服务器被修改为了 127.0.0.1

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443-LMLPHP

参考其他阿里云服务器的dns服务器配置,将其修改如下

options timeout: attempts: rotate single-request-reopen
; generated by /usr/sbin/dhclient-script
nameserver 100.100.2.138
nameserver 100.100.2.136
search localdomain

重新ping registry.npmjs.org 成功

ping registry.npmjs.org

Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443-LMLPHP

执行npm update也成功

参考资料

https://stackoverflow.com/questions/39592908/error-getaddrinfo-enotfound-registry-npmjs-org-registry-npmjs-org443

05-11 17:25