Installer Bun : macOS/Linux, bun init, TypeScript, bun install vs npm
Bun : bun init et bun install pour TypeScript avec moins d’outils.
Small APIs, CLIs, and front-end scripts still pay a tax: wire up ts-node, wait on npm installs, add a bundler. Bun is an all-in-one JavaScript/TypeScript runtime, package manager, test runner, and bundler — documented at bun.sh/docs.
Recherche installer Bun macOS Linux bun init TypeScript bun install npm need: install the Bun CLI, scaffold with bun init, execute .ts files directly, install deps with bun install, and understand how that differs from npm. Steps follow the official docs.
Pour qui Bun
JS/TS devs who want fewer moving parts
One binary runs scripts, installs packages, and runs tests — small services without webpack + ts-node first.
Teams staying on npm packages
bun install reads package.json; most npm libraries work. Lockfile is bun.lockb — commit it when Bun is canonical.
Fast local dev, Node in production
Use Bun locally for speed; ship on Node LTS in CI/production if required — document which runtime owns each repo.
Install Bun (macOS / Linux)
- 1
Official installer
Run the Installation command from the docs, e.g.
curl -fsSL https://bun.sh/install | bash. Open a new terminal and checkbun --version. - 2
macOS: Homebrew
brew tap oven-sh/bunthenbrew install bunwhen documented. Pick one install method to avoid duplicate binaries on PATH. - 3
Linux / WSL
Prefer the official script; verify with
which bunandbun --version. Locked-down hosts may need vendor packages from the docs. - 4
Upgrade
bun upgradefor latest stable (see CLI docs). Pin CI images when you upgrade.
Scaffold with bun init
- 1
Interactive setup
mkdir my-app && cd my-app, thenbun init. Choose blank, React, or other templates when prompted. - 2
Non-interactive
bun init -yfor a minimalpackage.jsonand entryindex.ts— confirm flags withbun init --help. - 3
Check entrypoints
Review
package.jsontypeand scripts;bun runuses them like npm.
Run TypeScript without extra tooling
bun run index.ts
bun index.ts
bun run devBun transpiles TypeScript/JSX built-in. Native Node addons and rare APIs may still differ — run your test suite before switching production runtime.
bun install vs npm
| Task | npm | Bun |
|---|---|---|
| install | npm install | bun install |
| add package | npm install pkg | bun add pkg |
| run script | npm run dev | bun run dev |
| lockfile | package-lock.json | bun.lockb |
bun install is usually faster (see Package manager docs). Repos with package-lock.json can trial Bun on a branch before adopting bun.lockb.
Bun speeds local installs and TS execution; Dockerfiles that use
node:22still need an explicit Node base — Bun and Node images are not drop-in replacements.
Pair on package.json or CI from the wbroom homepage — créer et rejoindre une salle.
Questions worth checking
Can Bun replace Node everywhere?
Depends on the app. Many npm packages work; native addons and edge APIs may not. Validate against the compatibility docs and your tests.
Keep both lockfiles?
Avoid two sources of truth. Pick Bun (bun.lockb + bun install --frozen-lockfile) or npm — document it in the README.
Windows?
This guide targets macOS/Linux. See Installation on bun.sh for Windows/WSL guidance.
Bun vs mise vs pnpm?
mise pins runtimes; pnpm optimizes Node installs; Bun bundles runtime + PM. Existing pnpm monorepos need a deliberate migration — greenfield scripts are easier to start on Bun.