这个也是网上搜的,亲自试过,非常好用!
一、npm设置淘宝镜像
1.通过config命令
安装完node后建议设置npm镜像以加速后面的过程(或使用科学上网工具)。注意:不要使用cnpm!cnpm安装的模块路径比较奇怪,packager不能正常识别!
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
npm info underscore (如果上面配置正确这个命令会有字符串response)
搜索镜像: https://npm.taobao.org
二、yarn设置淘宝镜像
1.通过config命令
安装完yarn后同理也要设置镜像源:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
yarn config get registry (如果上面配置正确这个命令会输出淘宝镜像地址)
来源:oschina
链接:https://my.oschina.net/u/2399426/blog/800239