npm yarn 设置淘宝源

npm使用淘宝镜像安装依赖包
定制 cnpm 命令行工具代替默认的 npm:

1
npm install -g cnpm --registry=https://registry.npmmirror.com/

npm持久使用淘宝镜像安装依赖包

1
npm config set registry https://registry.npmmirror.com/

使用这个命令查看是否设置成功

1
npm get registry 

设置回原来的

1
npm config set registry https://registry.npmjs.org/

yarn使用淘宝镜像

1
yarn config set registry http://registry.npm.taobao.org/