---
title: "npm vs Bun: Package Managers Explained"
description: "npm and Bun both install the libraries your project depends on. Learn what a package manager does and how npm and Bun differ."
type: "fundamental"
locale: "en"
category: "tools"
canonical: "https://agenticschool.dev/fundamentals/npm-vs-bun"
dateModified: "2026-06-12"
---

# npm vs Bun: Package Managers Explained

- Category: tools
- Updated: 2026-06-12
- Keywords: npm, Bun, package manager, dependencies, package.json
- Canonical URL: https://agenticschool.dev/fundamentals/npm-vs-bun
- Locale: en

> npm and Bun both install the libraries your project depends on. Learn what a package manager does and how npm and Bun differ.

npm and Bun are package managers: tools that download and install the libraries (called packages) your project depends on. npm comes bundled with Node.js and is the long-standing default, while Bun is a newer, much faster alternative that can also run your code. Both read the same package.json file that lists your dependencies, so for a beginner the practical difference is mostly speed and which commands you type.

## What a package manager does

Modern apps are built from hundreds of small reusable libraries rather than written from scratch. A package manager reads your project list of dependencies, downloads them, and keeps their versions consistent so the same project works the same way on any machine.

## The same commands, different tool

The everyday commands map almost one to one between npm and Bun, which makes switching easy.

```bash
npm install        # npm: install all dependencies
npm run dev        # npm: run the dev script

bun install        # bun: same thing, faster
bun run dev        # bun: run the dev script
```
Notice how similar they are. Bun is generally noticeably faster.

## Which should a beginner use

If a tutorial uses npm, use npm; if it uses Bun, use Bun. They are interchangeable enough that you can follow either. npm is guaranteed to be present because it ships with Node.js. Bun is worth installing once you want faster installs, but it is an extra tool to set up. Pick the one your project or course already uses and stay consistent.

## Common beginner confusions

The word "package" sounds technical but just means a reusable piece of code someone else wrote and published, so you do not have to. When you run install, the manager downloads all the packages your project lists into a folder called node_modules. That folder can get large, which is normal and harmless, and it is one of the things you keep out of Git because it can be rebuilt anytime from your dependency list. People also worry about the lock file (package-lock.json or bun.lock) that appears after installing. You do not edit it by hand; it simply pins exact versions so your project installs identically everywhere. Commit it, and let the package manager update it for you.

## FAQ

### Is Bun better than npm?

Bun is generally faster and can also run your code directly. npm is the universal default that ships with Node.js. For learning, either works; match whatever your project or tutorial uses.

### Do npm and Bun conflict?

It is best to pick one per project and stick with it, because each keeps its own lock file. Mixing them in the same project can cause confusing version differences.

### What is package.json?

It is the file that lists your project name, scripts and dependencies. Both npm and Bun read it to know what to install and which commands like "dev" or "build" to run.
