Linux 内核过低或 x64 CPU 不支持所需指令集时会报 illegal instruction 类错误;用 npm 全局安装需已有 Node/npm 环境,否则改用官方安装脚本;升级用 bun upgrade,想尝鲜需加 --canary。
bun
oven-sh活跃维护用 Zig 写的超快 JavaScript 运行时,把打包、测试和包管理集成在一起,用来替代 Node.js 和 npm 工具链。
Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
curl -fsSL https://bun.com/install | bash
npm install -g bun支持 Linux(x64/arm64)、macOS(x64/Apple Silicon)、Windows(x64/arm64);Linux 建议内核 5.6 以上,最低 5.1;x64 若报 illegal instruction 需查 CPU 要求。README 未提及显存或 GPU 要求。
一个可替代 Node.js 的极速 JS/TS 运行时,内置打包、测试与包管理
用 Zig 写的超快 JavaScript 运行时,把打包、测试和包管理集成在一起,用来替代 Node.js 和 npm 工具链。
核心能力
- 以 JavaScriptCore 为引擎、Rust 编写,降低启动时间与内存占用
- 作为 Node.js 的 drop-in 替代,可直接跑现有项目
- 内置测试运行器,用 bun test 执行测试
- 内置兼容 npm 的包管理器,用 bun install 装依赖
- 内置打包器与单文件可执行编译能力
容易踩的坑
- bun-v1.4.4Bun v1.4.4最新正式版2026-10-22 · 2026-10-22 10:11 UTC
To install Bun v1.4.4
curl -fsSL https://bun.com/install | bash # or you can use npm # npm install -g bunWindows:
powershell -c "irm bun.com/install.ps1|iex"To upgrade to Bun v1.4.4:
bun upgradeRead Bun v1.4.4's release notes on Bun's blog
Thanks to 39 contributors!
- @0xh3x
- @1cedsoda
- @alex-mextner
- @alii
- @Artoria2e5
- @bompus
- @C0casio45
- @cirospaciari
- @davidhevn
- @deepshekhardas
- @Dex4Sure
- @dylan-conway
- @EffortlessSteven
- @eriklangille
- @filipesarturi
- @fredluz
- @gerardp
- @gohryt
- @himself65
- @hughescr
- @Jarred-Sumner
- @jdjkelly
- @jecquas
- @jobansd
- @kernoeb
- @KilianB
- @MarshallOfSound
- @Neekoras
- @nikeee
- @nikelborm
- @ousamabenyounes
- @pjb3
- @RajeshKumar11
- @ralyodio
- @robobun
- @RubenPari
- @sosukesuzuki
- @steipete
- @SyMind
- bun-v1.4.3Bun v1.4.32026-10-10 · 2026-10-10 05:24 UTC
查看更新说明
To install Bun v1.4.3
curl -fsSL https://bun.sh/install | bash # or you can use npm # npm install -g bunWindows:
powershell -c "irm bun.sh/install.ps1|iex"To upgrade to Bun v1.4.3:
bun upgradeRead Bun v1.4.3's release notes on Bun's blog
Thanks to 8 contributors!
- bun-v1.4.2Bun v1.4.22026-09-05 · 2026-09-05 05:55 UTC
查看更新说明
To install Bun v1.4.2
curl -fsSL https://bun.sh/install | bash # or you can use npm # npm install -g bunWindows:
powershell -c "irm bun.sh/install.ps1|iex"To upgrade to Bun v1.4.2:
bun upgradeRead Bun v1.4.2's release notes on Bun's blog
Thanks to 3 contributors!
- bun-v1.4.1Bun v1.4.12026-09-04 · 2026-09-04 08:33 UTC
查看更新说明
To install Bun v1.4.1
curl -fsSL https://bun.sh/install | bash # or you can use npm # npm install -g bunWindows:
powershell -c "irm bun.sh/install.ps1|iex"To upgrade to Bun v1.4.1:
bun upgradeRead Bun v1.4.1's release notes on Bun's blog
Thanks to 7 contributors!
- bun-v1.4.0Bun v1.42026-08-20 · 2026-08-20 14:07 UTC
查看更新说明
To install Bun v1.4
curl -fsSL https://bun.com/install | bash # or you can use npm # npm install -g bunWindows:
powershell -c "irm bun.com/install.ps1|iex"To upgrade to Bun v1.4.0:
bun upgradeRead the blog post:
Thank you
Bun is free, open source, and MIT-licensed. We receive a lot of contributions from the community, and we'd like to thank everyone who fixed a bug or contributed since Bun v1.3.
- @190n
- @alanstott
- @alii
- @alinalihassan
- @amdad121
- @ant-kurt
- @anthonybaldwin
- @avarayr
- @baboon-king
- @billywhizz
- @bmwalters
- @Boshen
- @braden-w
- @c-stoeckl
- @carlsmedstad
- @chrislloyd
- @cirospaciari
- @coleleavitt
- @connerlphillippi
- @crishoj
- @csvlad
- @d4mr
- @darwin808
- @ddmoney420
- @dioro
- @djs5008
- @dylan-conway
- @Elfayer
- @emwadde
- @eroderust
- @fraidev
- @franklinfollis
- @gameroman
- @gaowhen
- @halil-pan
- @hamidrezahanafi
- @HK-SHAO
- @Hona
- @hoXyy
- @ig-ant
- @igorkofman
- @jackkleeman
- @Jarred-Sumner
- @jsparkdev
- @kirillmarkelov
- @kjanat
- @km-anthropic
- @kylekz
- @ldkhang1201
- @Lillious
- @lydiahallie
- @makuko
- @mariusz4044
- @markovejnovic
- @martinamps
- @mattermoran
- @MiniGod
- @mippbipp
- @mmitchellg5
- @nathanosoares
- @nektro
- @nfreya
- @NicoCevallos
- @nkxxll
- @ocodista
- @paperclover
- @pfgithub
- @prekucki
- @rekram1-node
- @remorses
- @RiskyMH
- @robjtede
- [@RyanGst
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Read the docs →
What is Bun?
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called bun.
At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Rust and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
bun run index.tsx # TS and JSX supported out-of-the-box
The bun command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need bun. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
bun test # run tests
bun run start # run the `start` script in `package.json`
bun install <pkg> # install a package
bunx cowsay 'Hello, world!' # execute a package
Install
Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon), and Windows (x64 & arm64).
Linux users — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
x64 users — if you see "illegal instruction" or similar errors, check our CPU requirements
# with install script (recommended)
curl -fsSL https://bun.com/install | bash
# on windows
powershell -c "irm bun.sh/install.ps1 | iex"
# with npm
npm install -g bun
# with Homebrew
brew tap oven-sh/bun
brew install bun
# with Docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
Upgrade
To upgrade to the latest version of Bun, run:
bun upgrade
Bun automatically releases a canary build on every commit to main. To upgrade to the latest canary build, run:
bun upgrade --canary
Quick links
-
Intro
-
Templating
-
Runtime
-
Package manager
-
Bundler
-
Compiler
-
Test runner
-
Package runner
-
API
- HTTP server (
Bun.serve) - HTTP routing
- HTTP error handling
- HTTP metrics
- WebSockets
- Workers
- Binary data
- Streams
- File I/O (
Bun.file) - Archive (tar)
- SQLite (
bun:sqlite) - PostgreSQL (
Bun.sql) - Redis (
Bun.redis) - S3 Client (
Bun.s3) - FileSystemRouter
- TCP sockets
- UDP sockets
- Globals
- Child processes (spawn)
- Cron (
Bun.cron) - WebView
- Transpiler (
Bun.Transpiler) - Hashing
- Colors (
Bun.color) - Console
- FFI (
bun:ffi) - C Compiler (
bun:fficc) - HTMLRewriter
- Cookies (
Bun.Cookie) - CSRF (
Bun.CSRF) - Secrets (
Bun.secrets) - YAML (
Bun.YAML) - TOML (
Bun.TOML) - JSON5
- JSONL
- Markdown
- Image processing
- Utils
- Node-API
- Glob (
Bun.Glob) - Semver (
Bun.semver) - DNS
- fetch API extensions
- HTTP server (
Guides
-
Deployment
-
Binary
- Convert a Blob to a string
- Convert a Buffer to a blob
- Convert a Blob to a DataView
- Convert a Buffer to a string
- Convert a Blob to a ReadableStream
- Convert a Blob to a Uint8Array
- Convert a DataView to a string
- Convert a Uint8Array to a Blob
- Convert a Blob to an ArrayBuffer
- Convert an ArrayBuffer to a Blob
- Convert a Buffer to a Uint8Array
- Convert a Uint8Array to a Buffer
- Convert a Uint8Array to a string
- Convert a Buffer to an ArrayBuffer
- Convert an ArrayBuffer to a Buffer
- Convert an ArrayBuffer to a string
- Convert a Uint8Array to a DataView
- Convert a Buffer to a ReadableStream
- Convert a Uint8Array to an ArrayBuffer
- Convert an ArrayBuffer to a Uint8Array
- Convert an ArrayBuffer to an array of numbers
- Convert a Uint8Array to a ReadableStream
-
Ecosystem
- Use React and JSX
- Use Gel with Bun
- Use Prisma with Bun
- Use Prisma Postgres with Bun
- Add Sentry to a Bun app
- Create a Discord bot
- Run Bun as a daemon with PM2
- Use Drizzle ORM with Bun
- Use Upstash Redis with Bun
- Build an app with Nuxt and Bun
- Build an app with Qwik and Bun
- Build an app with Astro and Bun
- Build an app with Remix and Bun
- Build a frontend using Vite and Bun
- Build an app with Next.js and Bun
- Run Bun as a daemon with systemd
- Build an HTTP server using Hono and Bun
- Build an app with SvelteKit and Bun
- Build an app with SolidStart and Bun
- Build an app with TanStack Start and Bun
- Build an HTTP server using Elysia and Bun
- Build an HTTP server using StricJS and Bun
- Containerize a Bun application with Docker
- Build an HTTP server using Express and Bun
- Use Neon Postgres through Drizzle ORM
- Server-side render (SSR) a React component
- Read and write data to MongoDB using Mongoose and Bun
- Use Neon's Serverless Postgres with Bun
-
HTMLRewriter
-
HTTP
- Hot reload an HTTP server
- Common HTTP server usage
- Write a simple HTTP server
- Configure TLS on an HTTP server
- Send an HTTP request using fetch
- Proxy HTTP requests using fetch()
- Start a cluster of HTTP servers
- Stream a file as an HTTP Response
- fetch with unix domain sockets in Bun
- Upload files via HTTP using FormData
- Streaming HTTP Server with Async Iterators
- Streaming HTTP Server with Node.js Streams
- Server-Sent Events (SSE) with Bun
-
Install
- Add a dependency
- Add a Git dependency
- Add a peer dependency
- Add a trusted dependency
- Add a development dependency
- Add a tarball dependency
- Add an optional dependency
- Generate a yarn-compatible lockfile
- Configuring a monorepo using workspaces
- Install a package under a different name
- Install dependencies with Bun in GitHub Actions
- Using bun install with Artifactory
- Configure git to diff Bun's lockb lockfile
- Override the default npm registry for bun install
- Using bun install with an Azure Artifacts npm registry
- Migrate from npm install to bun install
- Configure a private registry for an organization scope with bun install
-
Process
-
Read file
-
Runtime
- Delete files
- Run a Shell Command
- Import a JSON file
- Import a TOML file
- Import a YAML file
- Import a JSON5 file
- Set a time zone in Bun
- Set environment variables
- Re-map import paths
- Delete directories
- Read environment variables
- Import a HTML file as text
- Install and run Bun in GitHub Actions
- Debugging Bun with the web debugger
- Install TypeScript declarations for Bun
- Debugging Bun with the VS Code extension
- Inspect memory usage using V8 heap snapshots
- Define and replace static globals & constants
- Build-time constants with --define
- Codesign a single-file JavaScript executable on macOS
-
Streams
- Convert a ReadableStream to JSON
- Convert a ReadableStream to a Blob
- Convert a ReadableStream to a Buffer
- Convert a ReadableStream to a string
- Convert a ReadableStream to a Uint8Array
- Convert a ReadableStream to an array of chunks
- Convert a Node.js Readable to JSON
- Convert a ReadableStream to an ArrayBuffer
- Convert a Node.js Readable to a Blob
- Convert a Node.js Readable to a string
- Convert a Node.js Readable to an Uint8Array
- Convert a Node.js Readable to an ArrayBuffer
-
Test
- Spy on methods in
bun test - Bail early with the Bun test runner
- Mock functions in
bun test - Run tests in watch mode with Bun
- Use snapshot testing in
bun test - Skip tests with the Bun test runner
- Using Testing Library with Bun
- Update snapshots in
bun test - Run your tests with the Bun test runner
- Set the system time in Bun's test runner
- Set a per-test timeout with the Bun test runner
- Migrate from Jest to Bun's test runner
- Write browser DOM tests with Bun and happy-dom
- Mark a test as a "todo" with the Bun test runner
- Re-run tests multiple times with the Bun test runner
- Generate code coverage reports with the Bun test runner
- import, require, and test Svelte components with bun test
- Set a code coverage threshold with the Bun test runner
- Selectively run tests concurrently with glob patterns
- Spy on methods in
-
Util
- Generate a UUID
- Hash a password
- Escape an HTML string
- Get the current Bun version
- Upgrade Bun to the latest version
- Encode and decode base64 strings
- Compress and decompress data with gzip
- Sleep for a fixed number of milliseconds
- Detect when code is executed with Bun
- Check if two objects are deeply equal
- Compress and decompress data with DEFLATE
- Get the absolute path to the current entrypoint
- Get the directory of the current file
- Check if the current file is the entrypoint
- Get the file name of the current file
- Convert a file URL to an absolute path
- Convert an absolute path to a file URL
- Get the absolute path of the current file
- Get the path to an executable bin file
-
WebSocket
-
Write file
Contributing
Refer to the Project > Contributing guide to start contributing to Bun.
License
Refer to the Project > License page for information about Bun's licensing.