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"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章