windows(非wsl)安装和使用Claude code
Claude code目前已经支持Windows系统,不需要借助WSL来安装了
检查环境
要查看您是否已经安装了 Node.js 和 npm 并检查安装的版本,请运行以下命令:
node -v
npm -v
安装Claude code
Windows 终端执行以下命令
npm install -g @anthropic-ai/claude-code
配置代理
由于各种原因可能无法访问,需要给终端配置代理
步骤 1:找到并编辑 PowerShell 配置文件
如果还没有创建过,可以用以下命令创建
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
notepad $PROFILE
这会打开你的 PowerShell 配置文件。配置文件的默认路径通常是: C:\Users\你的用户名\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
步骤 2:添加代理函数
打开配置文件,添加下面内容:
function proxy {
$env:http_proxy = "http://127.0.0.1:端口"
$env:https_proxy = "http://127.0.0.1:端口"
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://127.0.0.1:端口")
Write-Host "Proxy enabled: http://127.0.0.1:端口" -ForegroundColor Green
}
function unproxy {
$env:http_proxy = $null
$env:https_proxy = $null
[System.Net.WebRequest]::DefaultWebProxy = $null
Write-Host "Proxy disabled" -ForegroundColor Yellow
}
function check-proxy {
if ($env:http_proxy -or $env:https_proxy) {
Write-Host "Current proxy settings:" -ForegroundColor Cyan
Write-Host "HTTP Proxy: $env:http_proxy"
Write-Host "HTTPS Proxy: $env:https_proxy"
} else {
Write-Host "No proxy is currently set." -ForegroundColor Cyan
}
}
步骤 3:保存并重新加载配置
保存文件,然后重新启动 PowerShell 或运行 . $PROFILE 来重新加载配置文件。
如何使用
现在,你可以在 PowerShell 中使用以下命令:
- 输入
proxy来启用代理 - 输入
unproxy来禁用代理 - 输入
check-proxy来查看当前的代理设置
注意事项
- 这个设置只影响当前的 PowerShell 会话,不会影响其他应用程序或系统级的代理设置。
- 如果你的代理地址和端口不是
127.0.0.1:10809,请相应地修改函数中的 URL。 - 如果你的代理需要认证,你需要修改函数来包含用户名和密码。

浙公网安备 33010602011771号