跳转到内容

安装选项

OpenCode 提供了跨不同平台的多种安装方法。使用下面的标签页找到最适合你操作系统的安装指南。

macOS 安装

推荐方法:官方安装脚本

在 macOS 上安装 OpenCode 最简单的方法是使用我们的官方安装脚本:

curl -sL opencode.ai/install | bash

Homebrew

对于喜欢使用 Homebrew 的 macOS 用户:

brew tap anomalyco/opencode
brew install opencode

手动安装

Apple Silicon (M1/M2/M3)

wget https://github.com/anomalyco/opencode/releases/latest/download/opencode-darwin-arm64
chmod +x opencode-darwin-arm64
mv opencode-darwin-arm64 /usr/local/bin/opencode

Intel

wget https://github.com/anomalyco/opencode/releases/latest/download/opencode-darwin-amd64
chmod +x opencode-darwin-amd64
mv opencode-darwin-amd64 /usr/local/bin/opencode

npm

你也可以通过 npm 安装 OpenCode:

npm install -g @anomalyco/opencode

验证安装

安装后,验证 OpenCode 是否已正确安装:

opencode --version

故障排除

如果你在安装过程中遇到任何问题,请在我们的 GitHub 仓库 上打开一个 issue。

更新 OpenCode

要将 OpenCode 更新到最新版本,你可以使用最初使用的相同安装方法。例如:

  • 官方脚本: curl -sL opencode.ai/install | bash
  • Homebrew: brew upgrade opencode
  • npm: npm update -g @anomalyco/opencode
  • AUR: paru -Syu opencodeyay -Syu opencode

卸载 OpenCode

要卸载 OpenCode:

  • 官方脚本/Homebrew/AUR: 使用包管理器的卸载命令
  • 手动安装: rm /usr/local/bin/opencode
  • npm: npm uninstall -g @anomalyco/opencode
  • Docker: 根据需要删除容器和镜像