登录 注册

bun (极速JavaScript运行时)

去点 Star
其他 bunbundlerjavascriptjavascriptcorejsxnodejs
96,663
Stars
5,275
Forks
618
Watchers
9,951
Open Issues
NOASSERTION
许可证
Rust
语言
2021-04-14
创建时间
2026-11-12
最近更新

项目能做什么

集运行时、打包器、测试运行器和包管理器于一身的极速 JavaScript 工具链。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

项目简介

Bun 是一个面向 JavaScript 与 TypeScript 应用的一体化(All-in-one)工具包,以单一可执行文件 bun 交付。其核心是专为无缝替代 Node.js(Drop-in replacement)而设计的 Bun 运行时。它基于 Rust 开发,底层由 JavaScriptCore 驱动,能够大幅缩短启动时间并减少内存占用,且开箱即用支持 TS 与 JSX。

核心功能

  • 快速运行时:开箱即用支持 TypeScript 与 JSX,直接执行代码。 bash bun run index.tsx # 原生支持 TS 和 JSX
  • 测试运行器(Test Runner):内置高效测试工具。 bash bun test # 运行测试
  • 脚本运行器:替代 npm run 等工具执行项目脚本。 bash bun run start # 执行 package.json 中的 start 脚本
  • 包管理器:兼容 Node.js 生态的超快包管理工具。 bash bun install <pkg> # 安装依赖包 bunx cowsay 'Hello, world!' # 免全局安装直接执行包命令
  • 版本更新: bash bun upgrade # 升级到最新稳定版 bun upgrade --canary # 升级到最新 canary 构建版

适合谁用

  • 正在使用 Node.js,希望在现有项目中几乎零成本迁移以获取极速启动和执行性能的开发者。
  • 厌倦了复杂的 TypeScript/JSX 转译配置,想要开箱即用开发体验的 JS/TS 开发者。

安装步骤

Bun 支持 Linux (x64 & arm64)、macOS (x64 & Apple Silicon) 以及 Windows (x64 & arm64)。

1. 官方脚本安装(推荐)

curl -fsSL https://bun.com/install | bash

2. Windows 安装

powershell -c "irm bun.sh/install.ps1 | iex"

3. 通过 npm 安装

npm install -g bun

4. 通过 Homebrew 安装 (macOS/Linux)

brew tap oven-sh/bun
brew install bun

5. 通过 Docker 运行

docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun

配置说明

此部分原文未详细说明具体配置内容(仅在链接中提及 bunfig.toml),请查看原仓库及官方文档。

常见问题

  • Linux 内核版本要求:强烈推荐 Linux Kernel 版本在 5.6 或更高,最低要求版本为 5.1。
  • x64 架构报错 "illegal instruction":如果在 x64 设备上遇到此错误或类似指令集报错,说明 CPU 可能未满足要求,请参考官方文档中的 CPU requirements 部分。
原始 README 摘录(英文原文,节选前 3000 字符)
<p align="center">
  <a href="https://bun.com"><img src="https://github.com/user-attachments/assets/50282090-adfd-4ddb-9e27-c30753c6b161" alt="Logo" height=170></a>
</p>
<h1 align="center">Bun</h1>

<p align="center">
<a href="https://bun.com/discord" target="_blank"><img height=20 src="https://img.shields.io/discord/876711213126520882" /></a>
<img src="https://img.shields.io/github/stars/oven-sh/bun" alt="stars">
<a href="https://twitter.com/jarredsumner/status/1542824445810642946"><img src="https://img.shields.io/static/v1?label=speed&message=fast&color=success" alt="Bun speed" /></a>
</p>

<div align="center">
  <a href="https://bun.com/docs">Documentation</a>
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
  <a href="https://bun.com/discord">Discord</a>
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
  <a href="https://github.com/oven-sh/bun/issues/new">Issues</a>
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
  <a href="https://github.com/oven-sh/bun/issues/159">Roadmap</a>
  <br />
</div>

### [Read the docs →](https://bun.com/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.

```bash
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.

```bash
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](https://bun.com/docs/installation#cpu-requirements)

```sh
# 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:

```sh
bun upgrade
```

Bun automatically releases a canary build on every commit to `main`. To upgrade to the latest canary build, run:

```sh
bun upgrade --canary
```

[View canary build](https://github.com/oven-sh/bun/releases/tag/can
阅读完整原文

项目深度分析 规则生成(AI 未配置)

综合评分 37.5 分。该项目在“个人可实施性”维度得 35 分,“付费可能性”维度得 20.0 分,差异化空间 40.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 bun 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2021-04-14,近 30 天仍在推送,发布过 100 个 Release
社区活跃Star 96,663 / Fork 5,275 / Issue 9,951(数据支持,可自行核实)
许可证NOASSERTION
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/oven-sh/bun.git
cd bun
docker compose up -d   # 或参考 README 中的 docker run 命令
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。