Help us improve
Share bugs, ideas, or general feedback.
Provides guidance on using Bun as JS runtime, package manager, bundler, and test runner. Covers when to choose Bun over Node, migration steps, and Vercel configuration.
npx claudepluginhub aaione/everything-claude-code-zhHow this skill is triggered — by the user, by Claude, or both
Slash command
/everything-claude-code:bun-runtimeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Bun 是一个快速的一体化 JavaScript 运行时和工具链:运行时、包管理器、打包器和测试运行器。
Provides guidance on using Bun as a runtime, package manager, bundler, and test runner, including migration from Node and Vercel deployment.
Guides using Bun as runtime, package manager, bundler, and test runner for JS/TS projects with Node comparisons, migration steps, and Vercel deployment.
Guides Bun runtime usage including CLI flags (--watch, --hot), watch/hot modes, env vars and .env files, bunfig.toml config, package.json scripts, and module resolution.
Share bugs, ideas, or general feedback.
Bun 是一个快速的一体化 JavaScript 运行时和工具链:运行时、包管理器、打包器和测试运行器。
使用场景:采用 Bun、从 Node 迁移、编写或调试 Bun 脚本/测试,或在 Vercel 或其他平台上配置 Bun。
bun install 比 npm/yarn 快得多。当前版本的 Bun 默认使用 bun.lock(文本)作为锁文件;旧版本使用 bun.lockb(二进制)。bun test,提供类似 Jest 的 API。从 Node 迁移:将 node script.js 替换为 bun run script.js 或 bun script.js。使用 bun install 替代 npm install;大多数包都能正常工作。使用 bun run 运行 npm 脚本;使用 bun x 进行 npx 风格的一次性运行。支持 Node 内置模块;在存在 Bun API 的地方优先使用 Bun API 以获得更好的性能。
Vercel:在项目设置中将运行时设为 Bun。构建:bun run build 或 bun build ./src/index.ts --outdir=dist。安装:使用 bun install --frozen-lockfile 进行可复现的部署。
# 安装依赖(创建/更新 bun.lock 或 bun.lockb)
bun install
# 运行脚本或文件
bun run dev
bun run src/index.ts
bun src/index.ts
bun run --env-file=.env dev
FOO=bar bun run script.ts
bun test
bun test --watch
// test/example.test.ts
import { expect, test } from "bun:test";
test("加法", () => {
expect(1 + 2).toBe(3);
});
const file = Bun.file("package.json");
const json = await file.json();
Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello");
},
});
bun.lock 或 bun.lockb)以确保可复现的安装。bun run 运行脚本。对于 TypeScript,Bun 原生运行 .ts 文件。