--- id: runtime-bun-deno-comparison title: Runtime 비교 — Bun / Deno / Node.js category: Coding status: draft source_trust_level: B verification_status: conceptual created_at: 2026-05-09 updated_at: 2026-05-09 tags: [runtime, bun, deno, node, vibe-coding] tech_stack: { language: "TS", applicable_to: ["Backend"] } applied_in: [] aliases: [Bun, Deno, Node.js, runtime, npm vs jsr, bunx, deno deploy] --- # Runtime 비교 > Node 가 표준 — 모든 npm 호환. **Bun = 빠른 빌드 + 호환, Deno = 보안 + 표준 web API + JSR 레지스트리**. 프로덕션 = Node 디폴트, 새 프로젝트 = Bun 시도 가치. ## 📖 핵심 개념 - Node: V8 + libuv. 가장 호환. - Bun: Zig + JSC. 빠른 install / test / bundler 내장. - Deno: V8 + Rust. 권한 모델 + Web 표준 + JSR. - 모두 TS native (Bun, Deno) 또는 tsx 필요 (Node). ## 💻 코드 패턴 ### Bun ```bash # install bun install bun add zod bun add -d typescript # 실행 bun run src/index.ts bun --watch src/index.ts # test bun test # bundler bun build src/index.ts --outdir dist --target node ``` ```ts // Bun.serve (built-in HTTP) Bun.serve({ port: 3000, fetch(req) { const url = new URL(req.url); if (url.pathname === '/health') return new Response('ok'); return new Response('not found', { status: 404 }); }, }); // SQLite native import { Database } from 'bun:sqlite'; const db = new Database('app.db'); db.query('SELECT * FROM users WHERE id = ?').get(id); ``` ### Deno ```bash # install (per import) deno run --allow-net main.ts # permission flags deno run --allow-net --allow-read=./data --allow-env main.ts deno run -A main.ts # all (개발용) # tasks deno task dev ``` ```ts // imports — URL 또는 JSR / npm import { z } from 'npm:zod@3'; import { serve } from 'jsr:@std/http'; import _ from 'https://esm.sh/lodash@4'; // 권한 명시 API const data = await Deno.readTextFile('./data.json'); // --allow-read Deno.serve({ port: 3000 }, (req) => new Response('hi')); ``` ### Web 표준 (모두 공유) ```ts // 표준 API — Node 18+, Bun, Deno 모두 동일 const r = await fetch('https://api.example.com'); const text = await r.text(); addEventListener('fetch', e => e.respondWith(handle(e.request))); ``` ### Node compat (Bun) ```ts // 거의 모든 npm 호환 import express from 'express'; // OK import { createServer } from 'http'; // OK import { db } from 'pg'; // OK (native binding 일부 issue) ``` ### Deno + Node (compat) ```ts import express from 'npm:express'; import process from 'node:process'; ``` 대부분 호환 — 일부 native module 제약. ### Test (Bun) ```ts import { test, expect } from 'bun:test'; test('add', () => { expect(1 + 1).toBe(2); }); ``` `bun test` 가 jest 비슷한 inline matcher. ### Test (Deno) ```ts import { assertEquals } from 'jsr:@std/assert'; Deno.test('add', () => { assertEquals(1 + 1, 2); }); ``` ### 성능 (대략) | 작업 | Node | Bun | Deno | |---|---|---|---| | Install (typical project) | 30s | 3s | 5s | | Cold start | 100ms | 50ms | 80ms | | Hot HTTP req/s | 50K | 90K | 60K | | TS execute | 별 도구 | native | native | ### Edge runtime (Cloudflare Workers / Vercel) - Subset of Web Standard APIs only. - Node 호환 = 일부. - Bun / Deno 의 Web API 와 호환성 좋음. ## 🤔 의사결정 기준 | 상황 | 추천 | |---|---| | Production 안전 | Node.js | | 빠른 dev cycle | Bun | | 보안 / 권한 | Deno | | Edge runtime 호환 | Web standard 위주 (Bun / Deno) | | 큰 npm 의존 | Node 또는 Bun | | Library publish | Node target + dual ESM/CJS | | Self-hosted | Node + PM2 또는 Bun | ## ❌ 안티패턴 - **Bun 에서 native module 가정**: pg / sharp 일부 issue. 검증. - **Deno 권한 -A 만 prod**: 보안 모델 무의미. - **Bun.serve API 가정 prod prod 가까움**: 아직 일부 edge case. - **Web 표준 API + Node 전용 API 혼용**: 호환성 깨짐. - **Bun 의 npm install 결과 Node 로 이동**: bun lockfile 만 나옴. yarn.lock 도 사용. - **Deno 의 https URL import + 안 cache**: 매번 fetch. ## 🤖 LLM 활용 힌트 - Production = Node. - Greenfield 빠른 = Bun. - Web 표준 / 보안 = Deno. - 모두 fetch / Response / URL standard 동일. ## 🔗 관련 문서 - [[TS_Build_Bundler_Patterns]] - [[Node_Streams_Patterns]] - [[DevOps_CI_CD_Pipeline_Patterns]]