$linuxjunkies
>

pnpm(1)

Fast, disk space efficient package manager for JavaScript and Node.js projects that uses a content-addressable filesystem to store dependencies.

UbuntuDebianFedoraArch

Synopsis

pnpm [COMMAND] [OPTIONS] [ARGS]

Description

pnpm is a package manager for Node.js that improves upon npm and yarn by using hard links and content-addressable storage to avoid duplication. It creates a non-flat node_modules structure and is significantly faster and more space-efficient than traditional package managers.

pnpm supports monorepos through workspaces, offers strict dependency resolution, and maintains compatibility with the npm registry. It uses a pnpm-lock.yaml file for deterministic installations across environments.

Common options

FlagWhat it does
-v, --versionDisplay the installed pnpm version
-h, --helpShow help information for a command
--global, -gOperate on the global store instead of the current project
--save, -SSave packages to dependencies in package.json
--save-dev, -DSave packages to devDependencies in package.json
--save-peer, -PSave packages to peerDependencies in package.json
--no-saveInstall packages without modifying package.json
--workspace-rootRun the command from the workspace root
-r, --recursiveRun the command on every project in the workspace
--filter <pattern>Run command only on packages matching the pattern

Examples

Install all dependencies listed in package.json and pnpm-lock.yaml

pnpm install

Add express to dependencies and install it

pnpm add express

Add eslint as a dev dependency

pnpm add -D eslint

Remove lodash package and update package.json

pnpm remove lodash

Run the 'start' script defined in package.json

pnpm start

Install dependencies for all packages in a monorepo workspace

pnpm -r install

Add typescript only to the @myapp/ui workspace package

pnpm --filter @myapp/ui add typescript

Clean up unreferenced packages from the pnpm store

pnpm store prune

Related commands