pnpm commands cheatsheet.
Install, add, run and manage workspaces — the pnpm commands you use every day. Tap to copy.
pnpm initCreate a package.json in the current folderpnpm installInstall all dependencies from package.jsonpnpm iShorthand for pnpm installpnpm add <pkg>Add a package as a dependencypnpm add -D <pkg>Add a package as a dev dependencypnpm add -g <pkg>Install a package globallypnpm add <pkg>@<version>Add a specific version of a packagepnpm remove <pkg>Remove a packagepnpm updateUpdate packages within allowed rangespnpm <script>Run a package.json script by namepnpm run <script>Run a custom script from package.jsonpnpm startRun the start scriptpnpm testRun the test scriptpnpm dlx <pkg>Run a package binary without installing itpnpm exec <cmd>Run a binary installed in node_modulespnpm why <pkg>Show why a package is installedpnpm outdatedShow packages with newer versions availablepnpm listList installed packagespnpm auditCheck dependencies for known vulnerabilitiespnpm store pruneRemove unreferenced packages from the storepnpm -r <cmd>Run a command in every workspace packagepnpm --filter <name> <cmd>Run a command in one workspace packagepnpm -w add <pkg>Add a dependency to the workspace rootWhat pnpm actually does
pnpm is a fast, disk-efficient package manager for Node.js projects, a drop-in alternative to npm and Yarn that reads the same package.json. Its headline trick is storage: instead of copying every dependency into each project, pnpm keeps one global content-addressable store and hard-links packages from it into your node_modules. The same version of a package is only ever written to disk once, no matter how many projects use it, so installs are quick and take far less space. As with any project, a single pnpm install reads package.json and sets up everything the code needs.
Adding the right way
pnpm uses add rather than install for individual packages. pnpm add <pkg> adds a normal dependency your app needs to run. pnpm add -D <pkg> marks it as a dev dependency — tools like test runners and bundlers that you need while building but not in production. pnpm add -g <pkg> installs globally so a command-line tool is available everywhere, and pnpm add <pkg>@<version> pins an exact version. Getting these distinctions right keeps your project lean and your deployments clean.
Scripts, dlx and exec
The scripts section of package.json is where projects define their commands. pnpm lets you run a script just by its name — pnpm <script> — or spell it out with pnpm run <script>, with start and test getting their own shortcuts. For one-off tools, pnpm dlx <pkg> downloads and runs a package's binary without adding it to your project (pnpm's answer to npx), while pnpm exec runs a binary that is already installed in node_modules.
Monorepos and maintenance
pnpm has first-class workspace support, which is why many monorepos reach for it. pnpm -r <cmd> runs a command across every package, and pnpm --filter <name> <cmd> targets just one. For upkeep, pnpm outdated shows what has newer versions, pnpm update moves them forward within safe ranges, pnpm why <pkg> explains why something is installed, and pnpm store prune clears unreferenced packages from the global store. These pair naturally with the npm commands you may already know and the Git commands for version control.