在使用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"