npm
1、查看一下当前源
npm config get registry
2、切换为淘宝源
npm config set registry https://registry.npm.taobao.org/
3、还原仓库地址(设置为官方镜像)
npm config set registry https://registry.npmjs.org/
yarn
1、查看一下当前源
yarn config get registry
2、切换为淘宝源
yarn config set registry https://registry.npm.taobao.org
3、还原仓库地址
yarn config set registry https://registry.yarnpkg.com
npm包的国内镜像registry.cnpmjs.org和registry.npm.taobao.org之间有什么区别和关系?
npm包的国内镜像一般有:registry.cnpmjs.org和registry.npm.taobao.org,
两者的同步时间不同,2018年10月18日淘宝是基本上每半个小时同步一次,而cnp是最后一次同步时间是2017年6月22日,基本上已经停止维护啦。所以最好用淘宝镜像。
npm config set registry https://registry.npm.taobao.org/
npm config get registry
- http://registry.cnpmjs.org/