各种包管理工具(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,目前不断完善中
相关推荐
Moment1 分钟前
面试官:一个接口使用postman这些测试很快,但是页面加载很慢怎么回事 😤😤😤
前端·后端·面试
诗书画唱4 分钟前
【前端面试题】JavaScript 核心知识点解析(第二十二题到第六十一题)
开发语言·前端·javascript
excel11 分钟前
前端必备:从能力检测到 UA-CH,浏览器客户端检测的完整指南
前端
前端小巷子18 分钟前
Vue 3全面提速剖析
前端·vue.js·面试
悟空聊架构24 分钟前
我的网站被攻击了,被干掉了 120G 流量,还在持续攻击中...
java·前端·架构
CodeSheep26 分钟前
国内 IT 公司时薪排行榜。
前端·后端·程序员
尖椒土豆sss30 分钟前
踩坑vue项目中使用 iframe 嵌套子系统无法登录,不报错问题!
前端·vue.js
遗悲风30 分钟前
html二次作业
前端·html
江城开朗的豌豆34 分钟前
React输入框优化:如何精准获取用户输入完成后的最终值?
前端·javascript·全栈
CF14年老兵34 分钟前
从卡顿到飞驰:我是如何用WebAssembly引爆React性能的
前端·react.js·trae