欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

用于开发的通用镜像 - 阿里云镜像

最编程 2024-04-05 13:13:32
...

开发常用镜像站 - 阿里云镜像站

阿里云官方镜像站:阿里巴巴开源镜像站-OPSX镜像站-阿里云开发者社区

镜像站用途

开发过程中经常需要使用第三方包或下载某些国外服务器上的资源,因为众所周知的原因,慢的一批。通过镜像站很轻松的解决这个问题,’本文以阿里云镜像站为例介绍

image

打开阿里云镜像站我们可以看到阿里云镜像站列表很多,几乎满足了日常开发需求。

镜像站应用

NPM

npm 镜像可以说是前端人员绕不过的坎了,官方源不能说经常出问题吧,只有经历过npm error 的人才能懂,并且阿里云 npm 镜像也十分丰富,点击进入中国 NPM 镜像首页

image

可以看到首页中支持的不少,开源镜像 栏目有更多详细内容,首页直观可以看到的就能满足大部分了:Node.js (当然这个下载的话速度还挺理想,用的不多)PhantomJS Mirror - 可编程的无头浏览器(常用于在线生成网页截图、爬虫)NPM Mirror - js包管理工具electron Mirror - js开发跨平台桌面应用 著名的vscode ...... 等等

使用方法(以 npm 为例):

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell" cid="n13" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># 单次使用 我一般常用这个
npm i package_name --registry=https://registry.npmmirror.com

一劳永逸换源法 之后的 npm i package_name 都会从该源下载了

npm config set registry https://registry.npmmirror.com</pre>

GOPROXY

go 的包管理工具,这里也不吹 阿里云的镜像了,goproxy.io 我也在用,以及号称 中国最可靠的 Go 模块代理 有时候不能保证都可以用,多准备几个备选

使用方法

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="shell" cid="n17" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"># (Linux || MacOS)

打开模块支持

export GO111MODULE=on

阿里云镜像

export GOPROXY=https://mirrors.aliyun.com/goproxy/

goproxy.io

export GOPROXY=https://goproxy.io,direct

中国最可靠的Go模块代理

export GOPROXY=https://goproxy.cn

Windows powershell

env:GO111MODULE = "on"env:GOPROXY = "https://goproxy.cn"

或者打开环境变量配置

变量名 值

GO111MODULE on

GOPROXY https://goproxy.cn

go 1.13 以上

go env -w GO111MODULE=on
go env -w GOPROXY=镜像源地址</pre>