我们知道国nodejs国际源的服务器在国外,安装前端依赖的时候经常访问超时。现在介绍一个nodejs换源管理工具,让你轻松切换国内的源
1.安装nrm
npm install -g nrm
2.验证安装
$ nrm --version
1.3.0
3.查看当前可用源地址
$ nrm ls
npm ---------- https://registry.npmjs.org/
yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
* taobao ------- https://registry.npmmirror.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
huawei ------- https://repo.huaweicloud.com/repository/npm/
4.测试可用源的响应速度
$ nrm test
npm ---------- timeout (Fetch timeout over 5000 ms)
yarn --------- 1058 ms
tencent ------ 1293 ms
cnpm --------- 1660 ms
* taobao ------- 189 ms
npmMirror ---- 952 ms
huawei ------- 443 ms
5.切换源
nrm use taobao