Yarn 安装过程出现 read ECONNRESET 错误

在使用yarn安装项目依赖包时,出现以下错误:

info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "http://r.cnpmjs.org/which/download/which-1.2.14.tgz: read ECONNRESET".

使用的是淘宝镜像

yarn config set registry  https://registry.npm.taobao.org

将仓库切换回 https://registry.npmjs.org/ ,同时使用vpn也还是出现同样的错误。
后来,在浏览器中直接打开 http://r.cnpmjs.org/which/download/which-1.2.14.tgz,发现链接已经无效,无法直接下载文件。于是尝试将yarn.lock文件中所有的 http://r.cnpmjs.org 修改为http://registry.npm.taobao.org,再次安装竟然成功了。

一般出现ECONNRESET错误会是网络问题,或者仓库有问题。使用排除法就能解决了。

当然也可以删除yarn.lock重新安装,或者使用npm重新安装,但是这样就违背使用yarn的初衷了。

如果安装 node_sass失败,先执行以下命令再执行 yarn install

yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/

安装 chromedriver失败,先执行以下命令再执行 yarn install

yarn config set "chromedriver_cdnurl" "https://npm.taobao.org/mirrors/chromedriver"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章