国内由于网络的原因,使用官方的npm或yarn访问下载依赖库会很慢,有时候还会出现无法访问的情况,这时候就需要我们给npm和yarn换一个国内的镜像源的,一般的我们可以将镜像换成淘宝的源,由于平时比较常用到的关系,所以就简单整理记录下,好之后查看。
- npm
$npm config get registry #获取当前镜像地址
$npm config set registry https://registry.npm.taobao.org #将镜像设为淘宝镜像
$npm config get registry #查看确认
- yarn
$yarn config get registry #获取当前镜像地址
$yarn config set registry https://registry.npm.taobao.org #全局替换镜像源
$yarn config get registry