bun

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Bun

Bun

Node.js 대신 Bun을 기본 런타임으로 사용.
替换Node.js使用Bun作为默认运行时。

설치

安装

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

명령어 매핑

命令映射

Node.js / npmBun
npm install
bun install
npm install <pkg>
bun add <pkg>
npm install -D <pkg>
bun add -d <pkg>
npm uninstall <pkg>
bun remove <pkg>
npm run <script>
bun run <script>
또는
bun <script>
npx <cmd>
bunx <cmd>
node <file>
bun <file>
npm init
bun init
npm create <template>
bun create <template>
Node.js / npmBun
npm install
bun install
npm install <pkg>
bun add <pkg>
npm install -D <pkg>
bun add -d <pkg>
npm uninstall <pkg>
bun remove <pkg>
npm run <script>
bun run <script>
bun <script>
npx <cmd>
bunx <cmd>
node <file>
bun <file>
npm init
bun init
npm create <template>
bun create <template>

프로젝트 초기화

项目初始化

bash
undefined
bash
undefined

새 프로젝트

新项目

bun init
bun init

템플릿 사용

使用模板

bun create next-app my-app bun create vite my-app
undefined
bun create next-app my-app bun create vite my-app
undefined

패키지 관리

包管理

bash
undefined
bash
undefined

설치 (bun.lockb 생성)

安装(生成bun.lockb)

bun install
bun install

의존성 추가

添加依赖

bun add express zod bun add -d typescript @types/node # devDependencies
bun add express zod bun add -d typescript @types/node # devDependencies

삭제

删除

bun remove lodash

> lockfile: `bun.lockb` (바이너리). `.gitignore`에 추가하지 않음.
bun remove lodash

> lockfile: `bun.lockb`(二进制文件)。无需添加到`.gitignore`中。

스크립트 실행

脚本执行

bash
undefined
bash
undefined

package.json scripts

package.json中的脚本

bun run dev bun run build
bun run dev bun run build

파일 직접 실행 (TypeScript 지원)

直接执行文件(支持TypeScript)

bun index.ts bun src/server.ts
bun index.ts bun src/server.ts

단축 (run 생략 가능)

简写(可省略run)

bun dev
undefined
bun dev
undefined

GitHub Actions

GitHub Actions

yaml
- uses: oven-sh/setup-bun@v{N} # 최신 버전 확인: gh api repos/oven-sh/setup-bun/releases/latest --jq '.tag_name'
- run: bun install
- run: bun test
yaml
- uses: oven-sh/setup-bun@v{N} # 查看最新版本: gh api repos/oven-sh/setup-bun/releases/latest --jq '.tag_name'
- run: bun install
- run: bun test