npm安装依赖的时候报错超时,如下:
npm error code ECONNRESET
npm error syscall read
npm error errno ECONNRESET
npm error network Invalid response body while trying to fetch https://registry.npmjs.org/element-plus: read ECONNRESET
npm error network This is a problem related to network connectivity.
npm error network In most cases you are behind a proxy or have bad network settings.
npm error network
npm error network If you are behind a proxy, please make sure that the
npm error network 'proxy' config is set properly. See: 'npm help config'
解决方法很简单:
执行以下代码,将 npm 的代理设置重置为无(即不使用代理),再次install就好了
npm config set proxy null
其他情况请参考下面的处理方法:
1、检查网络连接
2、切换淘宝源:
npm config set registry https://registry.npmmirror.com
推荐使用PNPM安装依赖,几经测试后发现目前pnpm最稳定,教程:
全局安装pnpm:
npm install -g pnpm //安装最新版本
npm install -g pnpm@5.15.0 //安装指定版本
安装项目的所有依赖:
pnpm install
pnpm install <package-name> //安装指定依赖
4、关闭防火墙
5、检查npm版本,确保你使用的Node.js版本与npm兼容