Introduction: Modern package managers (pnpm and Bun)

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Traditional package managers like npm have limitations that can lead to inefficient storage and slow installations. Modern alternatives like pnpm and Bun solve these problems through global stores and symlinks.

The problem with npm

When you run npm install, it:

  1. Downloads packages to your project’s node_modules folder
  2. Duplicates packages across different projects
  3. Can have multiple versions of the same package

This leads to wasted disk space (the same package stored multiple times) and slow installations.

How pnpm solves this

pnpm stores all packages in a single global location (~/.pnpm-store). Each package version is stored only once, regardless of how many projects use it.

Instead of copying packages, pnpm creates:

  • Hard links from the global store to a project-specific store
  • Symlinks from node_modules to the project-specific store
# Install pnpm
npm install -g pnpm

# Use it like npm
pnpm install
pnpm add hono

pnpm benefits

  • Each package version stored only once globally
  • Faster installations (no re-downloading)
  • Strict dependency resolution prevents phantom dependencies
  • Great for monorepos

How Bun solves this

Bun takes a similar approach with a global cache at ~/.bun/install/cache, plus additional optimizations:

# Install Bun
curl -fsSL https://bun.sh/install | bash

# Use it
bun install
bun add hono

Bun is written in Zig and is significantly faster than JavaScript-based package managers.

Practical comparison

Testing with the same dependencies:

ManagerInstall Timenode_modules Size
npm18 seconds180MB
pnpm6 seconds2MB (symlinks)
Bun3 seconds2MB (symlinks)

Migration

From npm to pnpm

npm install -g pnpm
rm -rf node_modules package-lock.json
pnpm install

From npm to Bun

curl -fsSL https://bun.sh/install | bash
rm -rf node_modules package-lock.json
bun install

When to use each

  • npm: Legacy projects, maximum compatibility
  • pnpm: Want disk savings and faster installs with Node.js compatibility
  • Bun: New projects, want maximum performance, comfortable with Bun’s runtime

Lessons in this unit:

0: Introduction
1: Installing Node.js on your computer
2: How to write your first Node.js program
3: Importing other files
4: Using npm to install packages
5: Using built-in modules
6: How to use the Node.js REPL
7: Reading files with Node
8: Writing files with Node
9: Build an HTTP Server
10: The Node Event emitter
11: How to read environment variables from Node.js
12: Node Buffers
13: Node.js Streams
14: How to use promises and await with Node.js callback-based functions
15: ▶︎ Modern package managers (pnpm and Bun)