我们在使用官方提供的npm源安装各种依赖包的时候,下载速度会很慢,通常需要更换npm源。
我们可以在终端中输入命令 npm config list 来查看 npm 源地址,默认地址为

metrics-registry = "https://registry.npmjs.org/"

国内常用的npm源地址为淘宝镜像:https://registry.npm.taobao.org/

方式一:使用命令直接更换

在终端输入以下命令,即可设置npm源地址为淘宝镜像。

npm set registry https://registry.npm.taobao.org/

这时使用 npm config list 查看 npm 源地址就变为

切换npm源的几种方法

删除方式为:npm config rm registry

方式二:使用nrm管理npm源

nrm是用来专门管理npm源地址的工具,我们使用nrm可以很方便的切换npm源地址。

  1. 全局安装nrm
 npm install nrm -g --save 
  1. nrm有默认配置,使用 nrm ls 查看,带 * 即为当前源地址
    切换npm源的几种方法

  2. nrm切换淘宝镜像

nrm use taobao
  1. 使用nrm添加镜像地址
nrm add r_name r_url # r_name 为镜像名字,r_url 为镜像地址
  1. 删除nrm镜像
nrm del r_name
  1. 测试镜像速度
nrm test r_name

参考文章:
https://www.cnblogs.com/Sky-Raining/p/10313600.html
https://www.cnblogs.com/wangmeijian/p/7072053.html

相关文章:

  • 2021-05-19
  • 2021-10-15
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2021-05-29
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2021-08-14
  • 2021-07-18
  • 2022-12-23
相关资源
相似解决方案