Yarn 是一個 JavaScript 包管理器,用於管理項目的依賴關係。默認情況下,Yarn 使用官方的 npm registry 作爲源來下載和安裝依賴項。
然而,由於官方源可能在國內訪問速度較慢,您可以使用國內的鏡像源來加快依賴項的下載速度。以下是一些常用的國內鏡像源:
-
淘寶鏡像:https://registry.npm.taobao.org使用命令
yarn config set registry https://registry.npm.taobao.org
將 Yarn 的源設置爲淘寶鏡像。 -
cnpmjs 鏡像:https://r.cnpmjs.org使用命令
yarn config set registry https://r.cnpmjs.org
將 Yarn 的源設置爲 cnpmjs 鏡像。 -
npm 鏡像:https://registry.npmjs.org使用命令
yarn config set registry https://registry.npmjs.org
將 Yarn 的源設置爲官方的 npm 鏡像。