.yarnrc
设置淘宝镜像
yarn config set registry https://registry.npm.taobao.org // 设置淘宝镜像
项目根(src同级)目录添加.yarnrc文件
为项目设置镜像源及包的路径
registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
其中 registry “https://registry.npm.taobao.org” 就是指定淘宝镜像源,是最重要的。
其余是指定对应包的下载路径。
添加文件且编辑结束后再使用yarn add命令就是从配置的镜像源中拉取需要的包,速度会更快。