Using Bun with OpenClaw: Install and Script Workflow

This page explains how to use Bun for dependency installation and package scripts in OpenClaw projects, while noting that Node is required for runtime commands. It covers setup, lockfile handling, and lifecycle script trust.

Read this when

  • You want to install dependencies or run package scripts with Bun
  • You hit Bun install/patch/lifecycle script issues

Warning

OpenClaw's CLI and Gateway are incompatible with Bun, as the required node:sqlite API is missing from that runtime. For any OpenClaw commands, install a Node version that is supported.

Bun can still be used as an optional tool for installing dependencies and executing package scripts. The default package manager stays pnpm, which has full support and is used by the documentation tooling. Bun does not support pnpm-lock.yaml and will disregard it.

Install

Install dependencies

bun install

Both bun.lock and bun.lockb are listed in gitignore, so no repository clutter occurs. To prevent lockfile writes entirely:

bun install --no-save

Build and test

bun run build
bun run vitest run

Any command that starts OpenClaw itself must still be executed through Node.

Lifecycle scripts

Bun requires explicit trust for dependency lifecycle scripts. For this repository, the scripts that are typically blocked are unnecessary:

  • baileys preinstall: verifies that the Node major version is at least 20 (OpenClaw needs Node 22.22.3+, 24.15+, or 25.9+, with Node 24 being the recommended choice)
  • protobufjs postinstall: outputs warnings for unsupported version patterns (no build artifacts result)

If a runtime problem occurs that requires these scripts, grant them explicit trust:

bun pm trust baileys protobufjs

Caveats

Certain package scripts have pnpm hardcoded internally (for instance check:docs, ui:*, protocol:check). When run through bun run, they still delegate to pnpm, so it is better to execute those directly via pnpm.