Runtime support
Run the same CLI on Bun and Node.js, and know where they differ.
Crust's command API works on Bun and Node.js. Start with the same entrypoint; change the command that runs it.
Run the same CLI
After installing Crust, save this as src/cli.ts:
import { Crust } from "@crustjs/core";
import { help } from "@crustjs/extensions";
const app = new Crust("my-cli")
.extend(help())
.args({ name: "name", type: "string", default: "world" })
.action(({ args, stdout }) => {
stdout(`Hello, ${args.name}!`);
});
await app.execute();| Runtime | Library minimum | Run the TypeScript example |
|---|---|---|
| Bun | 1.4+ | bun run src/cli.ts Ada |
| Node.js | 24+ | node src/cli.ts Ada |
Both print:
Hello, Ada!Node.js 24+ can run both the published libraries and the TypeScript command above. Use "type": "module" in package.json and erasable TypeScript syntax—no enums or parameter properties. See Node's type stripping for its limits.
Choose a runtime for your project
npx create-crust@latest my-cli --runtime nodeThis selects Node.js for the generated dev script, TypeScript settings, and target runtime. The next wizard question selects the build output independently; pass --artifact package or --artifact binary to skip it. All four combinations are supported. Defaults are Node.js packages and Bun binaries. Pass --runtime bun for Bun, the default runtime. See package setup for the build and release scripts.
The package manager does not choose the runtime. npm, pnpm, Yarn, and Bun can install dependencies for either Bun or Node.js projects.
Build separately from running
You don't need Bun to run Node.js source. crust build is separate, Bun-powered tooling, even when producing Node.js output. The packaged CLI can use its embedded Bun runtime; Node.js binaries additionally require a node on PATH that meets tsdown's executable requirements (Node.js 26+ with the bundled tsdown).
The runtime does not choose the output: crust.artifact does. A runtime package is JavaScript for the user's installed Bun or Node.js; a standalone binary embeds Bun or Node.js and needs no separately installed JavaScript runtime.
The distribution channel is a separate choice. npm's generated launcher needs Node.js to select and start a binary; direct downloads, Homebrew, or other installers can run that same binary without the launcher or Node.js. crust publish handles npm only. Continue to Build and distribution for targets and release layouts.