Bun is a fast all-in-one JavaScript runtime

To update or switch versions, run webi bun@<tag>.
(you can use @beta for pre-releases, or @x.y.z for a specific version)

Files

These are the files / directories that are created and/or modified with this install:

~/.config/envman/PATH.env
~/.local/opt/bun/
~/.local/opt/bun-<VERSION>/

Cheat Sheet

Bun is a wicked-fast JavaScript runtime for developer tooling, API servers, and edge computing.

It's built in Zig and provides a more curated, "batteries-included" approach to developing with JavaScript and JavaScript-ish languages - such as TypeScript, JSX, and TSX.

Run some xScript:

bun run ./hello.js
bun run ./hello.jsx
bun run ./hello.ts
bun run ./hello.tsx

Run a package from npm:

bun x jswt

More goodies:

bun help

(there's also a built-in development server and lots of stuff)

bun.sh/install vs webi

Bun has an official installer:

export BUN_INSTALL="$HOME/.bun"
curl -fsSL https://bun.sh/install | bash

You might want to still use webi if you want to be able to switch between versions.

How to install command line completions

bun completions

How to create a bun executable

  1. Create your script
    vim ./hello
    
    #!/usr/bin/env bun
    console.log('hello');
    
  2. Make it executable
    chmod a+x ./hello
    
  3. Run it
    ./hello
    

How to publish bun packages

At the time of this writing (bun v0.5.1), you'll still need to publish with npm.

npm is installed with node.

See Getting Started with NPM (as a developer).

How to install bun packages

You can run it with bun x:

bun x <whatever>

Or you can put the #!/usr/bin/env bun shebang before publishing, and install from npm:

bun install -g <whatever>
<whatever>

How to run a Bun program as a service

As a system service on Linux:

(note: swap 'my-project' and './my-project' for the name of your project and file)

  1. Install serviceman (compatible with systemd)
    webi serviceman
    source ~/.config/envman/PATH.env
    
  2. Go into your program's directory
    pushd ./my-project/
    
  3. Add your project to the system launcher, running as the current user
    serviceman add --name 'my-project' --daemon -- \
        bun run ./my-project.js
    
  4. Restart the logging service
    sudo systemctl restart systemd-journald
    

For macOS:

  1. Install serviceman (compatible with launchctl)
    webi serviceman
    source ~/.config/envman/PATH.env
    
  2. Go into your program's directory
    pushd ./my-project/
    
  3. Add your project to the system launcher, running as the current user
    serviceman add --agent --name 'my-project' -- \
        bun run ./my-project.js
    

Contribute

Report an Issue Submit Installer Star on GitHub