Files
bun.sh/docs/installation.md
Andrew Brown 500bd15fb5 add uninstall instructions (#5311)
it's always good to have uninstall instructions as well as install, and I couldn't find them anywhere else on the site.

IMO, this gives users a little more confidence to try new tools out, as they know it's easily reversible.

I'm not familiar with how to uninstall with Docker, so would appreciate some help there.

We could possibly add a note for "bash" on how to remove Bun from the `$PATH`.
2023-09-13 14:07:43 -07:00

3.5 KiB

Bun ships as a single executable that can be installed a few different ways.

macOS and Linux

{% callout %} Linux users — The unzip package is required to install Bun. Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. {% /callout %}

{% codetabs %}

$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
$ npm install -g bun # the last `npm` command you'll ever need
$ brew tap oven-sh/bun # for macOS and Linux
$ brew install bun
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
$ proto install bun

{% /codetabs %}

Windows

Bun provides a limited, experimental native build for Windows. At the moment, only the Bun runtime is supported.

  • bun <file>
  • bun run <file>

The test runner, package manager, and bundler are still under development. The following commands have been disabled.

  • bun test
  • bun install/add/remove
  • bun link/unlink
  • bun build

Upgrading

Once installed, the binary can upgrade itself.

$ bun upgrade

{% callout %} Homebrew users — To avoid conflicts with Homebrew, use brew upgrade bun instead.

proto users - Use proto install bun --pin instead. {% /callout %}

Bun automatically releases an (untested) canary build on every commit to main. To upgrade to the latest canary build:

$ bun upgrade --canary

View canary build

TypeScript

To install TypeScript definitions for Bun's built-in APIs in your project, install bun-types.

$ bun add -d bun-types # dev dependency

Then include "bun-types" in the compilerOptions.types in your tsconfig.json:

  {
    "compilerOptions": {
+     "types": ["bun-types"]
    }
  }

Refer to Ecosystem > TypeScript for a complete guide to TypeScript support in Bun.

Completions

Shell auto-completion should be configured automatically when Bun is installed.

If not, run the following command. It uses $SHELL to determine which shell you're using and writes a completion file to the appropriate place on disk. It's automatically re-run on every bun upgrade.

$ bun completions

To write the completions to a custom location:

$ bun completions > path-to-file      # write to file
$ bun completions /path/to/directory  # write into directory

Uninstall

If you need to remove Bun from your system, use the following commands.

{% codetabs %}

$ rm -rf ~/.bun # for macOS, Linux, and WSL
$ npm uninstall -g bun
$ brew uninstall bun
$ proto uninstall bun

{% /codetabs %}