共计 788 个字符,预计需要花费 2 分钟才能阅读完成。
国内 npm 源镜像(npm 加速下载)指定 npm 镜像
-
- 使用阿里云 镜像源加速 NPM
- 使用那个镜像,只需要 npm config set registry + 对应的镜像网址就好了
- 查看当前的镜像源:npm config get registry
- 推荐使用上面的方式指定 npm 镜像,当然方法不唯一,也可以用 nrm 去指定 npm 镜像
- 安装 nrm
- 查看可选的源
- 切换
npm 官方原始镜像网址是:
https://registry.npmjs.org
阿里云 NPM 镜像:
https://registry.npmmirror.com/
腾讯云 NPM 镜像:
https://mirrors.cloud.tencent.com/npm/
华为云 NPM 镜像:
https://mirrors.huaweicloud.com/repository/npm/
使用阿里云 镜像源加速 NPM
npm config set registry https://registry.npmmirror.com/
使用那个镜像,只需要 npm config set registry + 对应的镜像网址就好了
npm config set registry
查看当前的镜像源:npm config get registry
npm config get registry
推荐使用上面的方式指定 npm 镜像,当然方法不唯一,也可以用 nrm 去指定 npm 镜像
什么是 nrm
nrm 是一个 npm 源管理器,允许你快速地在 npm 源间切换。
安装 nrm
npm install -g nrm
如果安装失败,切换镜像仓库之后重新安装
可以先查一下这个网站有没有这个镜像 url+ 你要安装的镜像
有内容代表存在,可以安装
查看可选的源
nrm ls
切换
如果要切换到 taobao 源,执行命令
nrm use taobao
因为我原来用的就是阿里的,示例切换成腾讯的,再查询之后就变成腾信的了。
测试速度
nrm test
原文地址: 国内 npm 源镜像(npm 加速下载)指定 npm 镜像
正文完