> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 Bun 升级到最新版本

Bun 使用内置的 `bun upgrade` 命令自我升级。

```bash terminal icon="terminal" theme={null}
bun upgrade
```

`bun upgrade` 下载并安装 Bun 的最新稳定版本，替换当前安装的版本。

<Note>要查看当前 Bun 版本，请运行 `bun --version`。</Note>

***

## 验证升级

升级后，验证新版本：

```bash terminal icon="terminal" theme={null}
bun --version
# 输出：1.x.y

# 查看 Bun 二进制文件的确切提交
bun --revision
# 输出：1.x.y+abc123def
```

***

## 升级到金丝雀版本

金丝雀版在每次提交到 `main` 分支时发布。它们未经测试，但对于尝试新功能或在发布前验证 bug 修复很有用。

```bash terminal icon="terminal" theme={null}
bun upgrade --canary
```

<Warning>金丝雀版不推荐用于生产环境。它们可能包含 bug 或破坏性变更。</Warning>

***

## 切换回稳定版

如果你使用金丝雀版并想返回最新的稳定版本：

```bash terminal icon="terminal" theme={null}
bun upgrade --stable
```

***

## 安装特定版本

要安装特定版本的 Bun，请使用带版本标签的安装脚本：

<Tabs>
  <Tab title="macOS & Linux">
    ```bash terminal icon="terminal" theme={null}
    curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.3"
    ```
  </Tab>

  <Tab title="Windows">
    ```powershell PowerShell icon="windows" theme={null}
    iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.3.3"
    ```
  </Tab>
</Tabs>

***

## 包管理器用户

如果你使用包管理器安装的 Bun，请使用该包管理器进行升级，而不是用 `bun upgrade`，以避免冲突。

<Tip>
  **Homebrew 用户** <br />
  请使用 `brew upgrade bun`。

  **Scoop 用户** <br />
  请使用 `scoop update bun`。
</Tip>

***

## 参见

* [安装](/installation) — 首次安装 Bun
* [更新包](/pm/cli/update) — 将依赖项更新到最新版本
