在终端执行 npm install时,出现以下类似的报错时
npm ERR! code ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to http:/ /registry.cnpmjs.org/yarn failed, reason: getaddrinfo ENOTFOUND registry.cnpmjs.org
npm ERR! network This is a problem 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! A complete log of this run can be found in:
npm ERR! E:\nodejs\node_cache\_logs\2022-06-06T08_36_56_243Z-debug.log
解决方法如下所示:
- 在cmd终端输入以下命令,作用是设置代理
npm config set proxy=
- 2.然后使用淘宝镜像
npm config set registry https://registry.npm.taobao.org
- 下载所需要的包
eg:npm install -g jquery
jquery 这部分就是所需要的包