pnpm Cheat Sheet

Quick reference for pnpm commands: install, add, remove, workspaces, and more. Fast, disk-efficient Node.js package manager.

Install & Setup Add & Remove Run Scripts Workspaces Useful Commands

Install & Setup

npm install -g pnpm Install pnpm globally via npm
pnpm init Create a new package.json
pnpm install Install all dependencies from lockfile
pnpm install --frozen-lockfile Install without updating lockfile (CI mode)
pnpm env use --global lts Install and use the LTS version of Node.js

Add & Remove

pnpm add pkg Add a production dependency
pnpm add -D pkg Add a dev dependency
pnpm add -g pkg Install a package globally
pnpm remove pkg Remove a dependency
pnpm update pkg Update a specific package to latest

Run Scripts

pnpm run dev Run the dev script from package.json
pnpm exec cmd Execute a shell command in the project scope
pnpm dlx pkg Run a package without installing (like npx)
pnpm create app Scaffold a project using create-* package
pnpm start Run the start script (shorthand)

Workspaces

pnpm -w add pkg Add dependency to workspace root
pnpm --filter app add pkg Add dependency to a specific workspace package
pnpm -r run build Run build in all workspace packages recursively
pnpm -r --parallel run dev Run dev in all packages in parallel
pnpm deploy --filter app Deploy a workspace package with pruned dependencies

Useful Commands

pnpm store prune Remove unreferenced packages from the store
pnpm licenses list List licenses of all installed packages
pnpm outdated Check for outdated dependencies
pnpm why pkg Show why a package is installed (dependency chain)
pnpm audit Check for known security vulnerabilities

Try It Live

Test these patterns with our free JSON Formatter. No signup needed.

Open JSON Formatter →
Step-by-Step Guide

How to Format JSON Online

Read Guide →

More Cheat Sheets