Bun Install vs Bun Add: Choosing the Right Command
If you’ve switched to Bun, you’ve likely noticed two similar commands — bun install and bun add. They may look alike, but they serve different purposes depending on your workflow. Understanding their distinctions helps you manage dependencies efficiently and avoid confusion.
1. bun install — Reinstalling Dependencies
bun install is equivalent to npm install or yarn install. It reads your bun.lockb or package.json and installs everything listed there.
bun install✅ Use when:
- You’ve cloned a project and want to install existing dependencies.
- You’ve deleted your
node_modulesfolder. - You’re syncing dependencies after a version update.
⚙️ Bun optimizes installation using caching and parallel downloads, so it’s extremely fast compared to npm or yarn.
2. bun add — Installing New Packages
bun add is used when adding a new dependency to your project. It automatically installs the package and updates your package.json and bun.lockb.
bun add react
bun add -d typescript✅ Use when:
- You’re adding a new library.
- You want to save it as a dev dependency (
-dflag).
💡 Example:
bun add axiosThis instantly installs Axios and saves it to your project dependencies — much faster than npm install axios.
3. Key Differences at a Glance
| Feature | bun install | bun add |
|---|---|---|
| Purpose | Install all existing deps | Add a new dependency |
Updates package.json | ❌ No | ✅ Yes |
| Reads from lockfile | ✅ Yes | ✅ Yes |
| Common use | Setup or rebuild | Add libraries or dev tools |
4. Best Practices
- Use
bun installonly for setting up or syncing environments. - Use
bun addfor adding new dependencies. - Avoid mixing them unnecessarily — Bun handles dependency management automatically.
Summary
-
bun install→ Installs everything from yourpackage.json. -
bun add→ Adds and installs new dependencies.
By understanding when to use each, you’ll maintain a cleaner, faster, and more predictable Bun environment.