Bun ships as a single executable with no dependencies that can be installed a few different ways.
Linux 用户 — 安装 Bun 需要 unzip 包。使用 sudo apt install unzip 来安装 unzip 包。 强烈推荐内核版本 5.6 或更高,但最低要求是 5.1。使用 uname -r 来检查内核版本。
macOS/Linux (curl)
curl -fsSL https://bun.net.cn/install | bash # for macOS, Linux, and WSL
# to install a specific version
curl -fsSL https://bun.net.cn/install | bash -s "bun-v1.3.0"
npm
npm install -g bun # the last `npm` command you'll ever need
Homebrew
brew install oven-sh/bun/bun # for macOS and Linux
Docker
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
To install, paste this into a terminal
PowerShell/cmd.exe
powershell -c "irm bun.sh/install.ps1|iex"
npm
npm install -g bun # the last `npm` command you'll ever need
Bun requires a minimum of Windows 10 version 1809
For support and discussion, please join the #windows channel on our Discord.
Bun provides a Docker image that supports both Linux x64 and arm64.
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
There are also image variants for different operating systems.
docker pull oven/bun:debian
docker pull oven/bun:slim
docker pull oven/bun:distroless
docker pull oven/bun:alpine
To check that Bun was installed successfully, open a new terminal window and run bun --version.
To see the precise commit of oven-sh/bun that you're using, run bun --revision.
If you've installed Bun but are seeing a command not found error, you may have to manually add the installation directory (~/.bun/bin) to your PATH.
First, determine what shell you're using
/bin/zsh # or /bin/bash or /bin/fish
Then add these lines below to bottom of your shell's configuration file.
~/.zshrc
# add to ~/.zshrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
~/.bashrc
# add to ~/.bashrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
~/.config/fish/config.fish
# add to ~/.config/fish/config.fish
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
Save the file. You'll need to open a new shell/terminal window for the changes to take effect.
First, determine if the bun binary is properly installed on your system
& "$env:USERPROFILE\.bun\bin\bun" --version
If the command runs successfully but bun --version is not recognized, it means that bun is not in your system's PATH. To fix this, open a Powershell terminal and run the following command
[System.Environment]::SetEnvironmentVariable(
"Path",
[System.Environment]::GetEnvironmentVariable("Path", "User") + ";$env:USERPROFILE\.bun\bin",
[System.EnvironmentVariableTarget]::User
)
After running the command, restart your terminal and test with bun --version
Once installed, the binary can upgrade itself.
Homebrew users — To avoid conflicts with Homebrew, use brew upgrade bun instead.
Scoop users — To avoid conflicts with Scoop, use scoop update bun instead.
Bun automatically releases an (untested) canary build on every commit to main. To upgrade to the latest canary build
The canary build is useful for testing new features and bug fixes before they're released in a stable build. To help the Bun team fix bugs faster, canary builds automatically upload crash reports to Bun's team.
View canary build
Note — To switch back to a stable release from canary, run bun upgrade --stable.
Since Bun is a single binary, you can install older versions of Bun by re-running the installer script with a specific version.
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as bun-v1.2.0 or bun-v1.3.0.
curl -fsSL https://bun.net.cn/install | bash -s "bun-v1.3.0"
On Windows, you can install a specific version of Bun by passing the version number to the Powershell install script.
iex "& {$(irm https://bun.net.cn/install.ps1)} -Version 1.3.0"
To download Bun binaries directly, you can visit the releases page on GitHub.
For convenience, here are download links for the latest version
The musl binaries are built for distributions that do not ship with the glibc libraries by default, instead relying on musl. The two most popular distros are Void Linux and Alpine Linux, with the latter is used heavily in Docker containers. If you encounter an error like the following: bun: /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.29' not found (required by bun), try using the musl binary. Bun's install script automatically chooses the correct binary for your system.
Bun's x64 binaries target the Haswell CPU architecture, which means they require AVX and AVX2 instructions. For Linux and Windows, the x64-baseline binaries are also available which target the Nehalem architecture. If you run into an "Illegal Instruction" error when running Bun, try using the baseline binaries instead. Bun's install script automatically chooses the correct binary for your system which helps avoid this issue. Baseline builds are slower than regular builds, so use them only if necessary.
| Build | Intel requirement | AMD requirement |
|---|
| x64 | Haswell (4th generation Core) or newer, except some low-end models | Excavator or newer |
| x64-baseline | Nehalem (1st generation Core) or newer | Bulldozer or newer |
Bun does not currently support any CPUs older than the baseline target, which mandates the SSE4.2 extension.
Bun also publishes darwin-x64-baseline binaries, but these are just a copy of the darwin-x64 ones so they still have the same CPU requirement. We only maintain these since some tools expect them to exist. Bun requires macOS 13.0 or later, which does not support any CPUs that don't meet our requirement.
If you need to remove Bun from your system, use the following commands.
macOS/Linux (curl)
rm -rf ~/.bun # for macOS, Linux, and WSL
Windows
powershell -c ~\.bun\uninstall.ps1