bun README

The project's README from github.com/oven-sh/bun. As one markdown file: README.md.

Logo

Bun

stars Bun speed

Documentation   •   Discord   •   Issues   •   Roadmap

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

View canary build

Guides

bun (oven-sh/bun)

Searching Database…

96.3K ·GitHub
这是什么?Bun 是一个一体化的 JavaScript 和 TypeScript 工具包,它把运行时、打包器、测试运行器和包管理器都整合进一个名为 bun 的可执行文件中。
它是 Node.js 的替代品,还是要叠加在 Node.js 之上使用的东西?Bun 的核心是 Node.js 运行时的即插即用替代品,它用 Rust 编写,基于 JavaScriptCore 而不是 V8,因此大多数现有的 Node 项目几乎不需要修改就能运行。
怎么安装并开始使用?为你的操作系统安装单个 bun 可执行文件,然后用 'bun run' 运行脚本,用 'bun install/add' 管理包,并用 'Bun.build' 进行打包。
我需要先安装 Node.js 或 npm 吗?不需要,Bun 可以替代它们:它自带兼容 npm 的包管理器和兼容 Node.js 的运行时,所以不必单独安装 Node 或 npm。
把项目迁移过来之前有什么需要注意的坑吗?在 Linux 上强烈建议使用内核 5.6 及以上版本(最低要求 5.1),如果不满足要求,某些 CPU 可能会出现 'illegal instruction' 错误;遇到这种情况,请查阅 Bun 的 CPU 要求文档。
怎样才能及时获取新版本?运行升级命令即可获取最新的稳定版本;Bun 还会在每次提交到 main 分支时自动发布 canary 构建版本,用于测试更新的改动。
Bun 自带服务器和数据库 API 吗?自带。它内置了多种 API,例如用于 HTTP 服务器和 WebSocket 的 Bun.serve、bun:sqlite、用于 PostgreSQL 的 Bun.sql、Bun.redis 以及 S3 客户端,还有许多其他 API。
我能用 Bun 开发 React 或 JSX 项目吗?可以,Bun 内置了 JSX 支持,并提供了在 Bun 中使用 React、Next.js、Vite、Remix、Astro 等前端框架的文档指南。
内置的测试运行器和打包器能做什么?bun test 内置了模拟(mock)、快照和代码覆盖率功能,用于运行测试;Bun.build 可以打包 JavaScript/TypeScript、CSS 和 HTML,甚至能生成单文件可执行程序。
What are similar projects?rspack, esbuild, oxc, tsx, closure-compiler, WasmEdge, scriptc, browserify
Creator
oven-sh
Size
1.2 GB
Stars
96.3K
Age
5y
Commits · 90 Days