此篇用于记录各种常用的包管理器换源,长期更新维护(建议收藏)。
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 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: |
复制
使用配置文件设置全局源
- 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/ |
复制
检测源配置是否生效
复制
上诉源配置成功后执行此命令,正常会输出设置成功的源地址
Homebrew
常用的镜像源
- 官方源镜像站
- HomeBrew镜像源
https://github.com/Homebrew/brew.git
- HomeBrew Core镜像源
https://github.com/Homebrew/homebrew-core.git
- 清华大学镜像站
- 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
- 中国科学技术大学镜像站
- Homebrew核心库镜像源:
https://mirrors.ustc.edu.cn/homebrew-core.git
- Homebrew Bottles镜像源:
https://mirrors.ustc.edu.cn/homebrew-bottles
- 阿里云镜像站
- Homebrew核心库镜像源:
https://mirrors.aliyun.com/homebrew/homebrew-core.git
Homebrew为macos环境下包管理工具,更换源需要进入Homebrew核心库目录下,其中要注意的是,我们要更换的源除了HomeBrew
还有HomeBrew core
,HomeBrew 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
常用镜像源网站
- 阿里云镜像源:
- 地址:
http://mirrors.aliyun.com/repo/
- 下载示例:
http://mirrors.aliyun.com/repo/Centos-7.repo
- 腾讯云镜像源:
- 地址:
http://mirrors.cloud.tencent.com/
- CentOS系统安装示例:
yum install -y https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
- 腾讯云服务内网可直接使用
- 华为云镜像源
- 地址:
https://repo.huaweicloud.com/
- CentOS系统repo下载示例:
https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
- 网易云镜像源
- 地址:
http://mirrors.163.com/
- 搜狐开源
- 地址:
http://mirrors.sohu.com/
- CentOS系统repo下载示例:
http://mirrors.163.com/.help/CentOS7-Base-163.repo
- 清华大学TUNA源
- 中科大镜像源
以上镜像站只提供地址,具体下载链接需要根据当前系统版本在网站内找到对应的文件。
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
,目前不断完善中