当前位置: 首页 > article >正文

各种包管理工具(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/

查看当前源

npm config get register

更换源(最快)

npm config set registry registry https://registry.npmmirror.com/

使用nrm工具(灵活)

# 安装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

使用命令配置源(最快)

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源

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

命令行更换HomeBrew Core源

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

# 清理旧包
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配置示例:
      [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,如要操作建议备份

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

下载新YUM源配置文件

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

清除缓存操作

sudo yum clean all  
sudo yum makecache

验证

# 列出当前可用源集齐状态
yum repolist

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

更好的浏览体验建议访问本人自建网站 simplespace.site,目前不断完善中

http://www.kler.cn/news/362757.html

相关文章:

  • 硬件驱动应用
  • Docker:namespace环境隔离 CGroup资源控制
  • 小程序短链接生成教程
  • SQL 自学:游标(Cursors)的理解与应用
  • 【ROS2】Qt和ROS混合编程:多继承QObject和rclcpp::Node
  • SQL注入原理、类型、危害与防御
  • 【JavaScript】LeetCode:71-75
  • Zabbix 监控自动化
  • 论文翻译 | A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT (上)
  • Qt实现自定义目录添加到导航树(导航树存在目录追加,不存在创建)
  • Scala的内部对象
  • Python基于TensorFlow实现GRU-Transformer回归模型(GRU-Transformer回归算法)项目实战
  • Java安全编程:公钥加密和私钥签名的实践指南
  • 地方门户分类信息网站源码系统 用户可以自由发帖 PHP+MySQL组合开发 带完整的安装代码包以及搭建部署教程
  • 2024前端html5,css3面试题总汇
  • 在Ubuntu上部署MQTT服务器的详细指南
  • JavaScript完整笔记
  • 列表、元组、集合、字典和 pandas 数据框(DataFrame)之间的数据转换
  • 【Qt】QTableView添加下拉框过滤条件
  • 华为无线路由器设置成交换机
  • SpringBoot项目ES6.8升级ES7.4.0
  • STM32G474使用TIM2触发DAC输出输出正弦波
  • uniapp使用webView打开的网页有缓存如何解决(APP,微信小程序)
  • HarmonyOS鸿蒙分布式文件操作的时候权限问题
  • Rust中的Sync特征:确保多线程间安全共享数据
  • 软件工程--需求分析与用例模型