bun by brianlovin/claude-config
npx skills add https://github.com/brianlovin/claude-config --skill bun使用 Bun 作为默认的 JavaScript/TypeScript 运行时和包管理器。
| 替代以下命令 | 使用 |
|---|---|
node file.ts | bun file.ts |
ts-node file.ts | bun file.ts |
npm install | bun install |
npm run script |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
bun run script |
jest / vitest | bun test |
webpack / esbuild | bun build |
Bun 会自动加载 .env 文件 - 无需使用 dotenv。
优先使用这些 API 替代 Node.js 的对应功能:
| API | 用途 | 替代以下 |
|---|---|---|
Bun.serve() | 支持 WebSocket、HTTPS、路由的 HTTP 服务器 | express |
bun:sqlite | SQLite 数据库 | better-sqlite3 |
Bun.redis | Redis 客户端 | ioredis |
Bun.sql | Postgres 客户端 | pg, postgres.js |
Bun.file() | 文件操作 | node:fs readFile/writeFile |
Bun.$\cmd`` | 命令行指令 | execa |
WebSocket | WebSocket 客户端(内置) | ws |
使用 bun:test 进行测试:
import { test, expect } from "bun:test";
test("description", () => {
expect(1).toBe(1);
});
使用 bun test 运行测试。
使用 Bun.serve() 配合 HTML 导入,替代 Vite。支持 React、CSS、Tailwind。
服务器:
import index from "./index.html"
Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => Response.json({ id: req.params.id }),
},
},
development: { hmr: true, console: true }
})
HTML 文件:
<html>
<body>
<script type="module" src="./app.tsx"></script>
</body>
</html>
Bun 的打包器会自动转译 .tsx、.jsx、.js 文件。CSS 通过 <link> 标签打包。
使用 bun --hot ./server.ts 运行以启用热模块替换(HMR)。
详细 API 文档请参阅 node_modules/bun-types/docs/**.md。
每周安装量
85
代码仓库
GitHub 星标数
309
首次出现
2026年1月29日
安全审计
安装于
claude-code71
opencode61
codex58
cursor58
gemini-cli57
github-copilot56
Use Bun as the default JavaScript/TypeScript runtime and package manager.
| Instead of | Use |
|---|---|
node file.ts | bun file.ts |
ts-node file.ts | bun file.ts |
npm install | bun install |
npm run script | bun run script |
jest / vitest | bun test |
webpack / esbuild | bun build |
Bun automatically loads .env files - don't use dotenv.
Prefer these over Node.js equivalents:
| API | Purpose | Don't use |
|---|---|---|
Bun.serve() | HTTP server with WebSocket, HTTPS, routes | express |
bun:sqlite | SQLite database | better-sqlite3 |
Bun.redis | Redis client | ioredis |
Bun.sql | Postgres client | pg, postgres.js |
Bun.file() | File operations | node:fs readFile/writeFile |
Use bun:test for tests:
import { test, expect } from "bun:test";
test("description", () => {
expect(1).toBe(1);
});
Run with bun test.
Use HTML imports with Bun.serve() instead of Vite. Supports React, CSS, Tailwind.
Server:
import index from "./index.html"
Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => Response.json({ id: req.params.id }),
},
},
development: { hmr: true, console: true }
})
HTML file:
<html>
<body>
<script type="module" src="./app.tsx"></script>
</body>
</html>
Bun's bundler transpiles .tsx, .jsx, .js automatically. CSS is bundled via <link> tags.
Run with bun --hot ./server.ts for HMR.
For detailed API docs, see node_modules/bun-types/docs/**.md.
Weekly Installs
85
Repository
GitHub Stars
309
First Seen
Jan 29, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code71
opencode61
codex58
cursor58
gemini-cli57
github-copilot56
Node.js 环境配置指南:多环境管理、类型安全与最佳实践
10,500 周安装
Bun.$\cmd`` | Shell commands | execa |
WebSocket | WebSocket client (built-in) | ws |