前言

  • 在 Windows 下使用 PowerShell 和 MYSYS2 尝试 opencode

Windows Terminal + PowerShell

  • 下载安装 Node.js LTS
  • 设置 PowerShell 可运行脚本

    # 查看 
    Get-ExecutionPolicy
    # 设置
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • 设置国内镜像

    npm config set registry https://registry.npmmirror.com/
  • 查看镜像是否配置成功

    npm config get registry
  • PowerShell 下安装 opencode

    npm i -g opencode-ai@latest 
  • 验证 opencode 是否安装成功

     opencode --version
  • 设置代理

    $env:ALL_PROXY = 'socks5://127.0.0.1:10808'
  • 验证代理是否设置成功

    # 注意这里 curl.exe 不要写成 curl
    # PowerShell 下 curl 是 Invoke-WebRequest 的别名
    # 可以用 Get-Command curl 验证
    curl.exe ip.sb
  • 安装 Oh My OpenCode(可选)
  • 查看 Oh My OpenCode 是否安装成功
    image.png

Windows Terminal + MSYS2

  • 设置代理

    export ALL_PROXY='socks5://127.0.0.1:10808'
  • 安装 OpenCode

    curl -fsSL https://opencode.ai/install | bash
  • 通过查看版本信息测试安装是否成功

    opencode --version
本文出自 qbit snap

qbit
276 声望280 粉丝