npm下载太慢?切换npm源教程
最开始使用npm下载的一些插件的话用的国外的源,下载速度比较慢,有几种方式可以解决;
第一种
使用阿里的cnpm命令行工具代替npm命令行:(个人推荐这个)
npm install -g cnpm --registry=https://registry.npmmirror.com
检测是否安装成功
cnpm -v
安装好之后只需要将npm命令替换成cnpm即可;
举例:
cnpm install xxx
第二种:
修改npm源地址
npm config set registry https://registry.npmmirror.com
设置好之后,可以通过运行npm config list
查看是否配置成功。
; "builtin" config from C:\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\DELL\\AppData\\Roaming\\npm"
; "global" config from C:\Users\DELL\AppData\Roaming\npm\etc\npmrc
registry = "https://registry.npmmirror.com/"
或者通过npm config get registry
命令验证;
npm config get registry
第三种
使用nrm:
1.下载nrm:
npm install -g nrm
2.列出可以选择的源:
nrm ls
3.选择想要使用的源:
nrm use taobao
4.查看当前npm使用的源:
npm config get registry
5.后续的想安装什么插件直接使用
npm install xxx
版权申明
本文系作者 @季春二九 原创发布在季春二九 - Keith 的Blog站点。未经许可,禁止转载。
暂无评论数据