Course contentsShow
← JavaScript
Lesson 2532 of 2,72351. Package ManagementFree lesson

Installing and Using PNPM

Set up PNPM and learn its commands, noting differences and similarities to npm's interface.

Installing and Using PNPM

You'll learn how to set up PNPM on your system and use its commands, understanding how they compare to npm's familiar interface.

Getting PNPM on Your Machine

Since you already know npm, installing PNPM is straightforward. You can use npm itself:

npm install -g pnpm

Alternatively, use a standalone script that doesn't require Node.js to be installed first (useful for CI environments):

curl -fsSL https://get.pnpm.io/install.sh | sh -

Verify your installation:

pnpm --version

Using PNPM Commands

PNPM intentionally mirrors npm's command structure, so the learning curve is minimal:

# Initialize a project (just like npm init)
pnpm init

# Install dependencies (like npm install)
pnpm install

# Add a new package (like npm install <pkg>)
pnpm add lodash

# Add a dev dependency (like npm install -D)
pnpm add -D jest

# Remove a package (like npm uninstall)
pnpm remove lodash

# Run scripts (like npm run)
pnpm run build

# Update dependencies (like npm update)
pnpm update

Key Differences to Notice

While the commands look nearly identical, PNPM's symlink-based architecture (which you learned about previously) means installations are much faster and use less disk space. The pnpm-lock.yaml file replaces package-lock.json, and PNPM creates a different node_modules structure with symlinks to a global store.

PNPM also enforces strict dependency access—you can only import packages explicitly listed in your package.json, preventing accidental reliance on transitive dependencies.

Key Takeaway: PNPM uses npm-compatible commands but delivers faster installs, less disk usage, and stricter dependency isolation through its symlink architecture.