2025 npm 国内镜像源/加速列表换源(3月1日更新)

在使用npm过程中经常会遇到无法下载包的问题,本人在这里整理了几个npm使用国内镜像加速的方法,希望对大家有所帮助。淘宝镜像 npm 站全新上线,Web界面地址:npmmirror.com;npm 客户端使用地址:registry.npmmirror.com

国内可用 npm 源镜像

npm 官方原始镜像:https://registry.npmjs.org
淘宝 NPM 镜像:https://registry.npmmirror.com
阿里云 NPM 镜像:https://npm.aliyun.com
腾讯云 NPM 镜像:https://mirrors.cloud.tencent.com/npm
华为云 NPM 镜像:https://mirrors.huaweicloud.com/repository/npm
网易 NPM 镜像:https://mirrors.163.com/npm
中科院大学开源镜像站:http://mirrors.ustc.edu.cn
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn

使用方法

修改成腾讯云镜像源

1、命令

npm config set registry http://mirrors.cloud.tencent.com/npm/
  1. 验证命令
npm config get registry
 如果返回 http://mirrors.cloud.tencent.com/npm/,说明镜像配置成功。

修改成淘宝镜像源

  1. 命令
npm config set registry https://registry.npmmirror.com
  1. 验证命令
npm config get registry
 如果返回 https://registry.npmmirror.com,说明镜像配置成功。

修改成华为云镜像源

  1. 命令
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
  1. 验证命令
npm config get registry
 如果返回 https://mirrors.huaweicloud.com/repository/npm/,说明镜像配置成功。

通过使用淘宝定制的 cnpm 安装

  1. 安装 cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
  1. 使用 cnpm
cnpm install xxx

淘宝 npm

淘宝 npm 镜像站全新上线:

Web 界面地址:https://npmmirror.com

npm 客户端使用地址:https://registry.npmmirror.com


其他进阶操作

使用 nrm 切换镜像源

什么是 nrm?

nrm 是一个 npm 源管理器,允许你快速地在 npm 源间切换。

安装 nrm
npm install -g nrm
使用 nrm

查看可选的源

nrm ls
切换源

如果要切换到 taobao 源,执行命令

nrm use taobao
测试速度
nrm test

恢复官方镜像

如果需要解除镜像并恢复到官方源,请执行以下命令:

npm config set registry https://registry.npmjs.org
使用 Hugo 构建
主题 Stack,作者 Jimmy