Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called bun.
At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Rust and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
bun run index.tsx # TS and JSX supported out-of-the-box
The bun command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need bun. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
bun test # run tests
bun run start # run the `start` script in `package.json`
bun install <pkg> # install a package
bunx cowsay 'Hello, world!' # execute a package
Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon), and Windows (x64 & arm64).
Linux users — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
x64 users — if you see "illegal instruction" or similar errors, check our CPU requirements
# with install script (recommended)
curl -fsSL https://bun.com/install | bash
# on windows
powershell -c "irm bun.sh/install.ps1 | iex"
# with npm
npm install -g bun
# with Homebrew
brew tap oven-sh/bun
brew install bun
# with Docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
To upgrade to the latest version of Bun, run:
bun upgrade
Bun automatically releases a canary build on every commit to main. To upgrade to the latest canary build, run:
bun upgrade --canary
Intro
Templating
Runtime
Package manager
Bundler
Bun.inflateSync / Bun.gunzipSync have no output size limit (maxOutputLength silently ignored)
https://github.com/oven-sh/bun/issues/49960
Labels: enhancement, bun.js
Minified source maps have an empty names array
https://github.com/oven-sh/bun/issues/49959
Labels: bundler, sourcemaps
--aot: a write to the global object by Reflect.set or a computed key makes parseFloat unknown everywhere, and --explain does not name the write
https://github.com/oven-sh/bun/issues/49957
Labels: bug, single-file-executable, confirmed bug
Configuring a development environment for Bun can take 10-30 minutes depending on your internet connection and computer speed. You will need ~10GB of free disk space for the repository and build artifacts.
If you are using Windows, please refer to this guide
A Nix flake is provided as an alternative to manual dependency installation:
nix develop
# or explicitly use the pure shell
# nix develop .#pure
export CMAKE_SYSTEM_PROCESSOR=$(uname -m)
bun bd
This provides all dependencies in an isolated, reproducible environment without requiring sudo.
Using your system's package manager, install Bun's dependencies:
{% codetabs group="os" %}
$ brew install automake ccache cmake coreutils gnu-sed go icu4c libiconv libtool ninja pkg-config rustup-init ruby
$ sudo apt install curl wget lsb-release software-properties-common cmake git golang libtool ninja-build pkg-config ruby-full xz-utils
$ sudo pacman -S base-devel cmake git go libiconv libtool make ninja pkg-config python rustup sed unzip ruby
$ sudo dnf install clang23 llvm23 lld23 cmake git golang libtool ninja-build pkg-config ruby libatomic-static libstdc++-static sed unzip which libicu-devel 'perl(Math::BigInt)'
$ sudo zypper install go cmake ninja automake git icu rustup
{% /codetabs %}
Bun is written in Rust and requires a specific nightly toolchain (pinned in rust-toolchain.toml). Install Rust via rustup rather than your distro's rust/cargo packages — the build scripts use rustup to automatically install and update the pinned nightly:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Before starting, you will need to already have a release build of Bun installed, as we use our bundler to transpile and minify our code, as well as for code generation scripts.
{% codetabs %}
$ curl -fsSL https://bun.com/install | bash
$ npm install -g bun
$ brew tap oven-sh/bun
$ brew install bun
{% /codetabs %}
ccacheccache is used to cache compilation artifacts, significantly speeding up builds:
# For macOS
$ brew install ccache
# For Ubuntu/Debian
$ sudo apt install ccache
# For Arch
$ sudo pacman -S ccache
# For Fedora
$ sudo dnf install ccache
# For openSUSE
$ sudo zypper install ccache
Our build scripts will automatically detect and use ccache if available. You can check cache statistics with ccache --show-stats.
Bun requires LLVM 23.1.1 (clang is part of LLVM). This version is enforced by the build system — mismatching versions will cause memory allocation failures at runtime. In most cases, you can install LLVM through your system package manager:
{% codetabs group="os" %}
$ brew install llvm@23
$ # LLVM has an automatic installation script that is compatible with all versions of Ubuntu
$ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 23 all
$ sudo pacman -S llvm clang lld
$ sudo dnf install llvm clang lld-devel
$ sudo zypper install clang23 lld23 llvm23
{% /codetabs %}
If none of the above solutions apply, you will have to install it manually.
Make sure Clang/LLVM 23 is in your path:
$ which clang-23
If not, run this to manually add it:
{% codetabs group="os" %}
# use fish_add_path if you're using fish
# use path+="$(brew --prefix llvm@23)/bin" if you are using zsh
$ export PATH="$(brew --prefix llvm@23)/bin:$PATH"
# use fish_add_path if you're using fish
$ export PATH="$PATH:/usr/lib/llvm23/bin"
{% /codetabs %}
⚠️ Ubuntu distributions (<= 20.04) may require installation of the C++ standard library independently. See the troubleshooting section for more information.
After cloning the repository, run the following command to build. This may take a while as it will clone submodules and build dependencies.
$ bun run build
The binary will be located at ./build/debug/bun-debug. It is recommended to add this to your $PATH. To verify the build worked, let's print the version number on the development build of Bun.
$ build/debug/bun-debug --version
x.y.z_debug
VSCode is the recommended IDE for working on Bun, as it has been configured. Once opening, you can run Extensions: Show Recommended Extensions to install the recommended extensions for Rust and C++. rust-analyzer will pick up the workspace Cargo.toml automatically; the pinned toolchain in rust-toolchain.toml is used for analysis so diagnostics match the build.
If you use a different editor, point rust-analyzer (or your editor's Rust plugin) at the repo root — the Cargo workspace and rust-toolchain.toml are discovered automatically.
We recommend adding ./build/debug to your $PATH so that you can run bun-debug in your terminal:
$ bun-debug
The bd package.json script compiles and runs a debug build of Bun, only printing the output of the build process if it fails.
$ bun bd <args>
$ bun bd test foo.test.ts
$ bun bd ./foo.ts
A full debug build can take a few minutes when Rust or C++ has changed; cargo's incremental compilation makes subsequent Rust-only rebuilds much faster. If your development workflow is "change one line, save, rebuild", you will still spend too much time waiting for the link step. Instead:
cargo check -p <crate> (or bun run rust:check for the whole workspace) to