如果在前端开发使用 NPM 或者 YARN 下载过程中碰到网速非常慢,可以配置国内 淘宝镜像 来提升下载速度。具体方法如下
NPM
查询当前镜像
npm get registry
设置为淘宝镜像
npm config set registry https://registry.npm.taobao.org/
设置为官方镜像
npm config set registry https://registry.npmjs.org/
YARN
查询当前镜像
yarn config get registry
设置为淘宝镜像
yarn config set registry https://registry.npm.taobao.org/
设置node-sass镜像
node-sass的下载在国内是个老大难的问题,如果你不翻墙,默认下载极大可能会失败。怎么办呢? 配置下 node-sass 的二进制包镜像地址就行了
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
设置为官方镜像
yarn config set registry https://registry.yarnpkg.com