How to Install Bun on Ubuntu 26.04, 24.04 and 22.04

Last updated Wednesday, April 29, 2026 11:57 am Joshua James 7 min read

Bun is useful on Ubuntu when a JavaScript project needs one fast tool for running TypeScript, installing npm packages, bundling code, and starting a local HTTP server. To install Bun on Ubuntu, use the official install script for a standalone user-scoped runtime, or use npm when Node.js already manages your development environment.

Bun is not packaged in Ubuntu’s APT repositories, so sudo apt install bun is not the right path. The official script works the same on Ubuntu 26.04, 24.04, and 22.04, and it does not need root access after curl and unzip are available.

Install Bun on Ubuntu

Bun ships as a single precompiled executable. The official one-liner downloads the current stable Linux binary from Bun’s GitHub releases, installs it under ~/.bun/bin/, and adds that directory to your shell path.

Use these steps on a 64-bit Ubuntu system. Current Bun release assets include Linux x64, Linux x64 baseline, and Linux aarch64 builds, and the installer selects the matching archive automatically.

MethodChannelVersionUpdate CommandBest For
Official ScriptBun installation docsCurrent stable releasebun upgradeMost Ubuntu users, servers, and CI shells
npmnpm registry packageCurrent npm releasenpm update -g bunExisting Node.js and npm setups

The official script is the better default because it keeps Bun independent of Node.js and gives Bun its own self-update path. Use the npm method only when you already maintain global npm tools and want Bun managed through that same workflow.

Update Ubuntu Before Installing Bun

Refresh the package index and apply pending updates before installing new development tools.

sudo apt update && sudo apt upgrade

These commands use sudo for tasks that need root privileges. If your user is not in the sudoers file yet, follow the guide on how to add and manage sudo users on Ubuntu.

Install the two tools the official installer needs. curl downloads the script, and the unzip command extracts the release archive. Desktop installs often already have them, but minimal server and cloud images may not.

sudo apt install curl unzip

If you searched for a curl-free Bun install command, there is no separate curl-free version of the official one-liner. Install curl first, use npm if Node.js is already present, or download a release archive manually from the upstream Bun releases page.

Install Bun via the Official Install Script

Run the official Bun install script from bun.com. This works in a normal terminal, over SSH, and on Ubuntu Server because Bun is a terminal runtime, not a desktop application.

curl -fsSL https://bun.com/install | bash

The -fsSL flags tell the curl command to fail on HTTP errors, keep normal output quiet while still showing errors, and follow redirects. The pipe sends the installer script directly to bash.

The installer places the binary under ~/.bun/bin/. For Bash, it appends path entries to the first writable Bash startup file it finds, usually ~/.bash_profile or ~/.bashrc.

The installer prints the exact reload command at the end. On a default Ubuntu Bash account, it is usually:

source ~/.bashrc

If you use zsh or fish instead of Bash, the installer writes to ~/.zshrc or ~/.config/fish/config.fish. Run exec $SHELL for zsh, or start a new fish session after installation.

Install Bun with npm on Ubuntu

If Node.js and npm are already on your system, install Bun as a global npm package. If you need Node.js first, follow the separate guide to install Node.js on Ubuntu before using this method.

npm install -g bun

The -g flag installs the package globally. Use the same privilege model as your existing Node.js setup: user-owned NVM prefixes normally should not use sudo, while system-owned APT or NodeSource prefixes may require sudo npm install -g bun.

Verify the Bun Installation on Ubuntu

Check the installed Bun version. Bun point releases move quickly, so treat the exact patch number as variable.

bun --version

Example output from the current stable release:

1.3.13

For the build revision attached to that release, use --revision.

bun --revision
1.3.13+bf2e2cecf

Check that bunx is available too. You do not install bunx separately; it is Bun’s npx-style runner for npm package executables.

bunx --help

Relevant output begins with:

Usage: bunx [flags] <package><@version> [flags and arguments for the package]

Create a Bun Project on Ubuntu

Bun includes a built-in project scaffolding tool that generates a working TypeScript starter project. Bun can execute TypeScript files directly, so the starter file runs without a separate compile command. If you also need the standalone TypeScript compiler workflow, see how to install TypeScript on Ubuntu.

Scaffold a New Bun Project with bun init

Create a project directory and initialize it with Bun’s default template.

mkdir ~/bun-test && cd ~/bun-test
bun init -y

The -y flag accepts the default prompts. Bun generates starter files, then installs the TypeScript packages the template uses for editor support.

Relevant output includes:

 + .gitignore
 + index.ts
 + tsconfig.json (for editor autocomplete)
 + README.md

To get started, run:

    bun run index.ts

Run TypeScript with Bun on Ubuntu

Run the generated index.ts file to confirm the project works.

bun run index.ts
Hello via Bun!

You can also use bun run with package.json scripts, similar to npm run. Any script defined in the "scripts" section works with bun run <script-name>.

Build an HTTP Server with Bun.serve() on Ubuntu

Bun includes a built-in HTTP server API that does not require an external server package. Replace the contents of index.ts with this small server.

const server = Bun.serve({
  port: 3000,
  fetch(req) {
    const url = new URL(req.url);
    if (url.pathname === "/") return new Response("Hello from Bun!");
    return new Response("Not Found", { status: 404 });
  },
});

console.log(`Listening on http://localhost:${server.port}`);

Run the server.

bun run index.ts
Listening on http://localhost:3000

In a second terminal, test the local response.

curl http://localhost:3000
Hello from Bun!

Press Ctrl+C in the first terminal to stop the server when you are done testing.

Manage Bun Packages on Ubuntu

Bun handles common npm package workflows from the same bun command. Existing Node.js projects often work without changes, but projects that rely on V8 internals or a Node-specific CLI should still be tested before replacing Node.js in production.

TaskBun Commandnpm Equivalent
Add a dependencybun add <pkg>npm install <pkg>
Add a dev dependencybun add -d <pkg>npm install --save-dev <pkg>
Remove a dependencybun remove <pkg>npm uninstall <pkg>
Install all from package.jsonbun installnpm install
Run a scriptbun run <name>npm run <name>
Run an npm executablebunx <package>npx <package>

Add and Remove Bun Packages on Ubuntu

Add packages to a project the same way you would with npm. Bun resolves dependencies into a global cache, then links or copies them into the project depending on the platform and install strategy.

bun add express

For development-only dependencies like linters or formatters, use the -d flag.

bun add -d prettier

Remove a package with bun remove.

bun remove express

Clear the Bun Package Cache on Ubuntu

Bun stores downloaded packages in a global cache under ~/.bun/install/cache unless you override the cache location. Print the cache path first if you want to inspect it.

bun pm cache
/home/username/.bun/install/cache

Clear the cache when you need to reclaim disk space or force fresh package downloads.

bun pm cache rm

Relevant output includes:

Cleared 'bun install' cache
Cleared 0 cached 'bunx' packages

Upgrade Bun on Ubuntu

Bun manages its own updates independently of APT when installed with the official script. Run the self-update command to compare your local binary with the current stable release.

bun upgrade

If you are already current, the command reports the installed version:

Congrats! You're already on the latest version of Bun (which is v1.3.13)

To try pre-release builds, switch to the canary channel.

bun upgrade --canary

Switch back to the stable channel after testing.

bun upgrade --stable

Canary builds are useful for testing fixes and new features before they reach stable, but they may include regressions. Use them in disposable projects or test environments, not as the default runtime for production workloads.

To install a specific older Bun version, pass the upstream git tag to the installer script.

curl -fsSL https://bun.com/install | bash -s "bun-v1.3.3"

Troubleshoot Bun on Ubuntu

Most Bun installation problems on Ubuntu come from missing prerequisites, PATH configuration, or CPU compatibility on older x86_64 machines.

Fix “bun: command not found” on Ubuntu

This error means your shell cannot find the bun binary. Reload the shell file the installer updated, or open a new terminal.

source ~/.bashrc

If the error persists, use the grep command in Linux to verify that the PATH entries exist in your Bash configuration. The example below checks ~/.bashrc; if the installer output named ~/.bash_profile, substitute that file instead.

grep -E 'BUN_INSTALL|\.bun' ~/.bashrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

If those lines are missing from the file you checked, add them without duplicating existing entries. The example below uses ~/.bashrc, which is the default location on most Ubuntu Bash accounts.

grep -qxF 'export BUN_INSTALL="$HOME/.bun"' ~/.bashrc || printf '\n# bun\nexport BUN_INSTALL="$HOME/.bun"\n' >> ~/.bashrc
grep -qxF 'export PATH="$BUN_INSTALL/bin:$PATH"' ~/.bashrc || printf 'export PATH="$BUN_INSTALL/bin:$PATH"\n' >> ~/.bashrc
source ~/.bashrc

Fix “unzip is required to install bun” on Ubuntu

The official installer stops immediately when unzip is missing.

error: unzip is required to install bun

Install unzip along with curl, then run the Bun install command again.

sudo apt install curl unzip

Check Bun CPU Compatibility on Ubuntu

Bun’s standard Linux x64 binary targets CPUs with AVX2 support, while the baseline x64 binary supports older CPUs down to the SSE4.2 requirement. The current installer checks your CPU and automatically chooses the baseline binary when AVX2 is missing.

Check whether your CPU exposes AVX2.

grep -m1 -o avx2 /proc/cpuinfo
avx2

If the command returns no output, the installer should choose the baseline build automatically. Do not pass --baseline to the installer script; current Bun installer arguments treat the first value as a release tag, not as a baseline switch.

Remove Bun from Ubuntu

The removal path depends on the installation method. Script-installed Bun lives under your home directory, while npm-installed Bun follows your Node.js global package prefix.

Remove Script-Installed Bun from Ubuntu

The following command permanently deletes the Bun binary, package cache, completions, and any Bun-managed global packages under ~/.bun. Project-level node_modules directories are not affected.

Delete the Bun installation directory.

rm -rf ~/.bun

Open the shell configuration file the installer modified, then remove the Bun block. The example below uses ~/.bashrc; use ~/.bash_profile instead if the installer wrote there.

nano ~/.bashrc

Delete these lines if they are present.

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

Save the file, reload the shell configuration, and clear the current shell’s command cache before checking the result.

source ~/.bashrc
hash -r
command -v bun || echo "bun not found"
bun not found

Remove npm-Installed Bun from Ubuntu

If you installed Bun through npm, remove the global package with npm. Add sudo only if your original global install used a system-owned prefix.

npm uninstall -g bun

Clear the shell cache and verify that no other Bun install remains earlier in your PATH.

hash -r
command -v bun || echo "bun not found"
bun not found

Conclusion

Bun is available on Ubuntu with its runtime, package manager, bunx runner, and self-update command in place. Projects that still depend on V8-specific Node.js behavior can keep using Node.js on Ubuntu, while deployment-focused workflows often pair well with Docker on Ubuntu.

Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy me a coffee

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: