在使用npm命令时,如果直接从国外的仓库下载依赖包,下载速度会很慢且有时还下载不下来,这时候可以切换npm的仓库源试试。
//临时使用从淘宝仓库源下载
npm --registry=https://registry.npm.taobao.org install
//设置淘宝源
npm config set registry https://registry.npm.taobao.org
//设置回默认源
npm config set registry https://registry.npmjs.org
//查看源
npm config get registry
或者编辑 ~/.npmrc配置文件
registry = https://registry.npm.taobao.org