当前位置:首页 > 未命名 > 正文

windows powershell配置http代理

windows powershell配置http代理

yarn一个项目,npm postinstall 要 node lib/install.js,会从 raw.githubusercontent.com 拿 binary,但是没速度,一直报错 getaddrinfo ENOENT raw.githubusercontent.com,非常搞人心态,求助了一发很懂Windows的开发小哥哥才得救。以下内容都是记录:

下载一个好用的powershell 微软PowerShell Team的powershell7

地址:https://github.com/PowerShell/powershell/releases

Windows下载:PowerShell-7.1.0-win-x64.msi

下载之后,一路无脑点下一步就行,最后把所有checkbox全勾上。

方法一:命令行

Windows自带的powershell shift+右键。

刚装好的powershell7 直接右键就可以。

执行命令前,每次都要输入以下命令:

$env:HTTP_PROXY="http://127.0.0.1:7078"
$env:HTTPS_PROXY="https://127.0.0.1:7078"

方法二:给windows powershell 添加 function

打开命令行,执行

code $PROFILE 
(小白的注释:code ->vscode打开,PROFILE相当于一个cmd的配置文件,127.0.0.1相当于localhost,7078是开的代理的端口号,其他代理自己改一改)
function pc0 { $env:HTTP_PROXY="http://127.0.0.1:7078" }
function pc1 { $env:HTTPS_PROXY="https://127.0.0.1:7078" }
function unpc0 { $env:HTTP_PROXY="" }
function unpc1 { $env:HTTPS_PROXY="" }

在cmd敲 pc0 pc1 unpc0 unpc1就可以了,function名可以自己换。

windows powershell 美化

微信搜索公众号黑猫之家看更多资讯哦

更新时间 2021-07-15