国内镜像源 和 各种 编程语言 仓库存储路径/镜像源 配置

国内镜像站点

清华

https://mirrors.tuna.tsinghua.edu.cn/

中科大

https://mirrors.ustc.edu.cn/
https://mirrors.ustc.edu.cn/help/

Java (Maven)

maven 配置文件参考

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">

<!-- 本地仓库存储路径-->
<!--<localRepository>D:/Repository/maven</localRepository>-->

<mirrors>
<!--阿里云-->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <mirror>
      <id>maven</id>
      <mirrorOf>central</mirrorOf>
      <name>maven</name>
      <url>https://repo1.maven.org/maven2/</url>
    </mirror>

<!--网易-->
    <mirror>
      <id>nexus-163</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus 163</name>
      <url>http://mirrors.163.com/maven/repository/maven-public/</url>
    </mirror>

<!--腾讯-->
    <mirror>
      <id>nexus-tencentyun</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus tencentyun</name>
      <url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
    </mirror>

<!--开源中国-->
    <mirror>
      <id>CN</id>
      <name>OSChina Central</name>
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>
</settings>

Node

npm 默认全局及缓存位置

C:\Users\[用户名]\AppData\Roaming\npm				# 通过命令 npm config get prefix 获取
C:\Users\[用户名]\AppData\Roaming\npm_cache		# 通过命令 npm config get cache 获取

npm 修改全局及缓存位置

# 示例
npm config set prefix "D:\Repository\node\npm_global"
npm config set cache "D:\Repository\node\npm_cache"

yarn 的安装路径和缓存路径

查看各种路径命令

  • 查看 yarn 全局bin位置
    yarn global bin
    
  • 查看 yarn 全局安装位置
    yarn global dir
    
  • 查看 yarn 全局cache位置
    yarn cache dir
    

修改路径命令

  • 改变 yarn 全局bin位置
    yarn config set prefix "D:\Repository\yarn\data"
    
  • 改变 yarn 全局安装位置
    yarn config  set global-folder "D:\Repository\yarn\data\global"
    
  • 改变 yarn 全局cache位置
    yarn config set cache-folder "D:\Repository\yarn\cache"
    
  • 改变 yarn 全局 link 位置
    yarn config set link-folder "D:\Repository\yarn\data\link"
    

pnpm

查看 pnpm 存储路径

pnpm store path

修改 pnpm 存储路径

pnpm config set store-dir

清除 pnpm 缓存

pnpm store prune

npmmirror

npm

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

yarn

yarn config set registry https://registry.npmmirror.com/ --global

pnpm

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

Python3

pip

用户家目录下

创建 pip/pip.ini

Windows 可位于 用户家目录\AppData\Roaming\pip (优先级更高)

[global]
timeout = 3000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
extra-index-url = http://mirrors.aliyun.com/pypi/simple/
	https://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
	mirrors.aliyun.com
	pypi.mirrors.ustc.edu.cn

pip 的 安装位置

查看 pip 安装路径
pip show pip
修改 pip 安装路径
# 示例
pip config set global.target "D:\\Repository\\pip\\packages"

pip 的缓存位置

  • windows

默认位于用户家目录下/cache/pip

  • linux
    /家目录/.cache/pip
  • mac
    /Users/用户名/Library/Caches/pip

可使用环境变量 PIP_CACHE_DIR 指定缓存存储路径

也可以

通过命令修改
# 示例
pip config set global.cache-dir "D:\\Repository\\pip\\cache"
清理pip缓存文件夹
pip cache purge

解决 修改python 安装路径后找不到包 的问题

查看 python 配置环境文件地址
python -m site

** 3.12 下不起作用 **

  1. 到 python 的安装路径
  2. 修改 python 安装路径/Lib/site.py
    搜索 并修改 修改USER_SITE及USER_BASE值
    USER_SITE = r"D:\\Repository\\pip\\packages"
    USER_BASE = r"C:\Storage\D\Enviroment\Python\"
    

使用环境变量指定
https://docs.python.org/zh-tw/3.12/library/site.html
配置 环境变量 PYTHONUSERBASE 和 PYTHONNOUSERSITE

PYTHONNOUSERSITE = "D:\\Repository\\pip\\packages"
PYTHONUSERBASE  = "C:\Storage\D\Enviroment\Python\"

配置环境变量 PYTHONPATH 添加 python 库的搜索路径

PYTHONPATH = "D:\Repository\pip\packages"

Golang

镜像站点

国内

七牛

https://goproxy.cn/

全球

官方

https://goproxy.io/

配置镜像

# 启用 Go Modules 功能
go env -w GO111MODULE=on
# 1. 七牛 CDN
go env -w  GOPROXY=https://goproxy.cn,direct

查看是否配置成功

go env | grep GOPROXY

修改存储路径

配置环境变量

工作目录

GOPATH = "C:\Storage\D\Repository\go\workspace"

缓存

GOCACHE = "C:\Storage\D\Repository\go\cache"
清理缓存
go clean -cache
go clean --modcache

Rust

用户家目录下

创建 .cargo/config.toml

中科大源
[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
清华源

https://mirrors.tuna.tsinghua.edu.cn/help/crates.io-index/

[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"