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

# 升级 Bun 到最新版本

Bun 可以使用内置的 `bun upgrade` 命令自我升级。这是获取最新功能和修复的最快方式。

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun upgrade
```

这会下载并安装最新的稳定版本的 Bun，替换当前已安装的版本。

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

***

## 验证升级

升级后，验证新版本：

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun --version
# 输出：1.x.y

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

***

## 升级到 canary 版本

Canary 版本会在每次提交到 `main` 分支时自动发布。这些版本未经测试，但适合尝试新功能或在正式发布前验证修复的 bug。

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun upgrade --canary
```

<Warning>Canary 版本不建议用于生产环境。它们可能包含错误或破坏性更改。</Warning>

***

## 切换回稳定版本

如果你使用的是 canary 版本，想返回最新的稳定发布版本：

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun upgrade --stable
```

***

## 安装指定版本

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

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

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

***

## 包管理器用户

如果你是通过包管理器安装 Bun，请使用对应包管理器进行升级，避免使用 `bun upgrade` 造成冲突。

<Tip>
  **Homebrew 用户** <br />
  为避免与 Homebrew 冲突，请使用 `brew upgrade bun` 升级。

  **Scoop 用户** <br />
  为避免与 Scoop 冲突，请使用 `scoop update bun` 升级。
</Tip>

***

## 另请参阅

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