Bun JavaScript 运行时与工具链
bun 集运行时、包管理器、测试器和打包器于一体,追求速度和 Node.js 兼容。它适合新项目和脚本,但生产使用前要验证依赖兼容性。
bun --version
bun run app.ts
bun app.ts
bun --watch app.ts
bun install
bun add express
bun add -d typescript
bun remove express
bun test
bunx cowsay hello
bun build ./src/index.ts --outdir dist
bun build --compile ./app.ts --outfile app
bun init
bun install 生成的 lockfile 与 npm/pnpm 不同;团队要统一工具。bunx 会下载并执行包;版本要固定,避免供应链风险。--compile 产物包含运行时,体积和平台相关性要提前评估。node — Node.js 运行时deno — 另一种 JS 运行时npm — 包管理器