博主最近搬砖辛苦,前面刚搬完数据库的砖,现在就要和前端对接测试了。然而,把前端文件下载完毕,安装依赖时却报一大堆错误。天坑!因此,博主记录踩坑过程,希望能帮助大家。
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"
npm ERR! node v4.4.4
npm ERR! npm v2.15.1
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND xn--rvg xn--rvg:80
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! C:\Users\Administrator\npm-debug.log
看了一下 log 输出,感觉应该与网络、代理相关(被墙)。网上搜了一下,果不其然。坑爹啊!想必程序员都经常遇见此类问题,而解决此问题的方法也很简单。原文链接
- 设置代理
npm config get proxy
npm config get https-proxy
如果返回值不为null,继续执行:
(这一步很重要,一定要保证两个命令的返回值都为null,话说回来,应该出现这个错误这两个返回值有不为null的)
npm config set proxy null
npm config set https-proxy null
- 设置注册表
npm config set registry http://registry.cnpmjs.org/
Ok! 如此,博主又可以愉快的搬砖了!