How-To Guide
How to Install Bun
Bun is a fast, all-in-one JavaScript runtime that combines Node.js, npm, and a bundler in a single tool. Here's how to install it in under 5 minutes.
📋 What You'll Need
- A computer running Windows 10+, macOS, or Linux
- A terminal (PowerShell, Terminal, or bash)
- About 200 MB of free disk space
- 5 minutes of your time
✅ Bun is completely free and open source.
🥟 What Is Bun?
Bun is a JavaScript runtime like Node.js, but built for speed. It runs JavaScript and TypeScript directly, includes a package manager, a bundler, a test runner, and a transpiler — all in one binary.
Use it when you want:
- Faster install times than npm (often 10-25x)
- To run TypeScript without a separate compiler
- One tool instead of Node + npm + esbuild + jest
Open Your Terminal
Windows users: open PowerShell (not Command Prompt). Mac and Linux: open Terminal.
Run the Install Command
macOS / Linux:
curl -fsSL https://bun.sh/install | bash
Windows (PowerShell):
powershell -c "irm bun.sh/install.ps1 | iex"
Or via npm (works on any OS if you already have Node.js):
npm install -g bun
Verify Installation
Close and reopen your terminal, then run:
bun --version
You should see something like 1.1.30. If you get "command not found", restart your terminal — Bun adds itself to your PATH on install.
Test with a Script
Create a file called hello.ts (yes, TypeScript works natively):
const message: string = "Hello from Bun!";
console.log(message);
Run it:
bun run hello.ts
You should see Hello from Bun! — no compilation step needed. 🎉
💡 Bun runs .ts files directly. No tsc compile step, no ts-node. It parses TypeScript on the fly.
🧠 Essential Bun Commands
bun install # install dependencies (like npm install)
bun add react # add a package (like npm install react)
bun add -d typescript # add a dev dependency
bun remove lodash # remove a package
bun run script.ts # run a script
bun test # run tests
bun build ./index.ts # bundle for production
If you know npm, you already know Bun — the commands map one-to-one.
⚖️ Bun vs Node.js
- Speed: Bun starts up faster and installs packages much faster
- TypeScript: Bun runs .ts directly; Node needs compilation
- Ecosystem: Node has 15+ years of libraries; Bun runs most of them but not all edge cases
- Stability: Node is battle-tested; Bun is newer but maturing fast
- Best for: Bun for new projects and speed; Node for maximum compatibility
🔧 Troubleshooting
"bun: command not found"
Restart your terminal. The installer adds Bun to your PATH, but the current session doesn't pick it up until you reopen.
Windows: install script blocked
Run PowerShell as Administrator, or use the npm fallback: npm install -g bun.
Package doesn't work with Bun
Bun supports most Node packages, but a few use Node-specific APIs. If a package fails, fall back to Node.js for that project.