各种包管理工具(npm,pip,yum,brew...)换镜像源

此篇用于记录各种常用的包管理器换源,长期更新维护(建议收藏)。

NPM

常用源地址

各种源地址

  • 官方源 https://registry.npmjs.org/
  • 淘宝源 https://registry.npmmirror.com/
  • 淘宝源(旧)https://registry.npm.taobao.org
  • 阿里云 https://npm.aliyun.com
  • 腾讯云 https://mirrors.cloud.tencent.com/npm/
  • 网易云 ttps://mirrors.163.com/npm/
  • 中科大 http://mirrors.ustc.edu.cn/
  • 清华开源 https://mirrors.tuna.tsinghua.edu.cn/

查看当前源

shell 复制代码
npm config get register

更换源(最快)

shell 复制代码
npm config set registry registry https://registry.npmmirror.com/

使用nrm工具(灵活)

shell 复制代码
# 安装nrm
npm install nrm -g --save
# 查看可用源
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/
	
# 切换源
nrm use taobao 

# 测试速度
nrm test taobao

# 适用nrm添加镜像地址
nrm add 镜像名称 镜像地址

# 删除nrm镜像
nrm del 镜像名称

PIP

常用的国内镜像源

  • 官方源:https://pypi.org/simple
  • 清华大学: https://pypi.tuna.tsinghua.edu.cn/simple
  • 中国科学技术大学: https://pypi.mirrors.ustc.edu.cn/simple/
  • 阿里云: http://mirrors.aliyun.com/pypi/simple/
  • 豆瓣: http://pypi.douban.com/simple

下载时临时换源

复制代码
pip install 要安装的包名 -i https://pypi.tuna.tsinghua.edu.cn/simple

使用配置文件设置全局源

  • Linux或者Macos等类Unix系统:在~/.pip/pip.conf 中编辑配置(可能初始不存在,需要自己创建)
  • Windows: 通常位于%当前python安装目录下%\pip\pip.ini
pip.ini/pip.conf
复制代码
[global]
index-url = http://pypi.douban.com/simple

使用命令配置源(最快)

shell 复制代码
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

检测源配置是否生效

复制代码
pip config list

上诉源配置成功后执行此命令,正常会输出设置成功的源地址

Homebrew

常用的镜像源

  1. 官方源镜像站
  • HomeBrew镜像源 https://github.com/Homebrew/brew.git
  • HomeBrew Core镜像源 https://github.com/Homebrew/homebrew-core.git
  1. 清华大学镜像站
  • Homebrew核心库镜像源:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
  • Homebrew Cask镜像源:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
  • Homebrew Bottles镜像源:https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
  1. 中国科学技术大学镜像站
  • Homebrew核心库镜像源:https://mirrors.ustc.edu.cn/homebrew-core.git
  • Homebrew Bottles镜像源:https://mirrors.ustc.edu.cn/homebrew-bottles
  1. 阿里云镜像站
  • Homebrew核心库镜像源:https://mirrors.aliyun.com/homebrew/homebrew-core.git

Homebrew为macos环境下包管理工具,更换源需要进入Homebrew核心库目录下,其中要注意的是,我们要更换的源除了HomeBrew还有HomeBrew coreHomeBrew Cask, HomeBrew Bottles,我们这里只处理HomeBrew以及Core的源地址

命令行更换HomeBrew源

shell 复制代码
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

命令行更换HomeBrew Core源

shell 复制代码
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

更新HomeBrew

shell 复制代码
# 清理旧包
brew cleanup
# 更新brew
brew update

Yum

常用镜像源网站

  1. 阿里云镜像源:

    • 地址:http://mirrors.aliyun.com/repo/
    • 下载示例:http://mirrors.aliyun.com/repo/Centos-7.repo
  2. 腾讯云镜像源:

    • 地址:http://mirrors.cloud.tencent.com/
    • CentOS系统安装示例:yum install -y https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
    • 腾讯云服务内网可直接使用
  3. 华为云镜像源

    • 地址:https://repo.huaweicloud.com/
    • CentOS系统repo下载示例:https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
  4. 网易云镜像源

    • 地址:http://mirrors.163.com/
  5. 搜狐开源

    • 地址:http://mirrors.sohu.com/
    • CentOS系统repo下载示例:http://mirrors.163.com/.help/CentOS7-Base-163.repo
  6. 清华大学TUNA源

    • 地址:http://mirrors.tuna.tsinghua.edu.cn/

    • CentOS 7配置示例:

      复制代码
      [tuna]  
      name=TUNA  
      baseurl=http://linux.tuna.tsinghua.edu.cn/centos/7/os/x86_64/  
      gpgcheck=1  
      gpgkey=http://linux.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-tuna
  7. 中科大镜像源

    • 地址:http://mirrors.ustc.edu.cn/

    • CentOS 7配置示例:

      ini 复制代码
      [ustc]  
      name=USTC  
      baseurl=http://mirrors.ustc.edu.cn/centos/7/os/x86_64/  
      gpgcheck=1  
      gpgkey=http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-7

以上镜像站只提供地址,具体下载链接需要根据当前系统版本在网站内找到对应的文件。

yum是RPM包管理工具,centos自带,使用率很高,yum的源管理主要是文件形式存储在 /etc/yum.repos.d/目录下,默认源是CentOS-Base.repo,如要操作建议备份

shell 复制代码
# 强烈建议任何设计源文件的修改都要备份
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载新YUM源配置文件

shell 复制代码
# 按照系统环境下在对应的源文件,这里的连接是centos7适配文件
# 如手动下载文件,需要改名为 CentOS-Base.repo
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清除缓存操作

shell 复制代码
sudo yum clean all  
sudo yum makecache

验证

shell 复制代码
# 列出当前可用源集齐状态
yum repolist

更多内容后续更新,过时内容不定期维护

更好的浏览体验建议访问本人自建网站simplespace.site,目前不断完善中
相关推荐
崔庆才丨静觅4 小时前
hCaptcha 验证码图像识别 API 对接教程
前端
passerby60615 小时前
完成前端时间处理的另一块版图
前端·github·web components
掘了5 小时前
「2025 年终总结」在所有失去的人中,我最怀念我自己
前端·后端·年终总结
崔庆才丨静觅5 小时前
实用免费的 Short URL 短链接 API 对接说明
前端
崔庆才丨静觅5 小时前
5分钟快速搭建 AI 平台并用它赚钱!
前端
崔庆才丨静觅6 小时前
比官方便宜一半以上!Midjourney API 申请及使用
前端
Moment6 小时前
富文本编辑器在 AI 时代为什么这么受欢迎
前端·javascript·后端
崔庆才丨静觅6 小时前
刷屏全网的“nano-banana”API接入指南!0.1元/张量产高清创意图,开发者必藏
前端
剪刀石头布啊6 小时前
jwt介绍
前端
爱敲代码的小鱼6 小时前
AJAX(异步交互的技术来实现从服务端中获取数据):
前端·javascript·ajax