PNPM
PNPM

Init & Config

Create a package.json file with all defaults in the current directory

$pnpm init

Set the default npm registry URL for pnpm

$pnpm config set registry https://registry.npmjs.org/

Get the currently configured registry URL

$pnpm config get registry

Remove the registry config key, reverting to default

$pnpm config delete registry

List all active pnpm configuration values

$pnpm config list

List all pnpm config values in JSON format

$pnpm config list --json

Configure pnpm to save exact versions instead of semver ranges

$pnpm config set save-exact true

Set a custom directory for the pnpm content-addressable store

$pnpm config set store-dir /path/to/store

Set the directory for globally installed packages

$pnpm config set global-dir /path/to/global

Set the directory where global package binaries are linked

$pnpm config set global-bin-dir /usr/local/bin

Hoist all dependencies to node_modules root for maximum compatibility

$pnpm config set shamefully-hoist true

Set a glob pattern for which packages to hoist to the root node_modules

$pnpm config set hoist-pattern *

Set a pattern for packages to hoist to the root for tooling access

$pnpm config set public-hoist-pattern *eslint*

Set the node linker strategy to hoisted for compatibility with npm layout

$pnpm config set node-linker hoisted

Set the node linker strategy to isolated for strict dependency isolation

$pnpm config set node-linker isolated

Automatically install missing peer dependencies

$pnpm config set auto-install-peers true

Disable errors on missing or incompatible peer dependencies

$pnpm config set strict-peer-dependencies false

Always use the lockfile as-is without attempting updates

$pnpm config set prefer-frozen-lockfile true

Set an HTTP proxy for pnpm network requests

$pnpm config set proxy http://proxy.example.com:8080

Set an HTTPS proxy for pnpm network requests

$pnpm config set https-proxy http://proxy.example.com:8080

Install & Add Packages

Install all dependencies listed in package.json using the lockfile

$pnpm install

Install only production dependencies, skipping devDependencies

$pnpm install --prod

Install only devDependencies

$pnpm install --dev

Install dependencies without updating the lockfile, failing if out of sync

$pnpm install --frozen-lockfile

Install dependencies and allow updating the lockfile if needed

$pnpm install --no-frozen-lockfile

Force reinstall all packages, bypassing the store cache

$pnpm install --force

Install packages without running any lifecycle scripts

$pnpm install --ignore-scripts

Use cached packages when available, falling back to network

$pnpm install --prefer-offline

Install using only the local store, failing if any package is missing

$pnpm install --offline

Hoist all packages to root node_modules for this install

$pnpm install --shamefully-hoist

Update the lockfile without installing anything into node_modules

$pnpm install --resolution-only

Update pnpm-lock.yaml only without touching node_modules

$pnpm install --lockfile-only

Fix broken lockfile entries without a full reinstall

$pnpm install --fix-lockfile

Install dependencies suppressing all output except errors

$pnpm install --reporter=silent

Install with append-only progress output suitable for CI logs

$pnpm install --reporter=append-only

Install the latest version of express as a production dependency

$pnpm add express

Install a specific version of express as a production dependency

$pnpm add express@4.18.2

Install the latest tagged version of express

$pnpm add express@latest

Install express at the latest version matching the given semver range

$pnpm add express@^4.0.0

Install express and pin the exact version in package.json

$pnpm add express --save-exact

Install typescript as a development dependency

$pnpm add typescript --save-dev

Install an exact version of typescript as a devDependency

$pnpm add typescript --save-dev --save-exact

Install lodash as an optional dependency

$pnpm add lodash --save-optional

Install lodash as a peer dependency

$pnpm add lodash --save-peer

Install typescript globally

$pnpm add -g typescript

Update pnpm itself to the latest version globally

$pnpm add -g pnpm@latest

Install multiple packages simultaneously as production dependencies

$pnpm add react react-dom

Install a scoped package as a devDependency

$pnpm add @types/node --save-dev

Install a package directly from a GitHub repository URL

$pnpm add git+https://github.com/user/repo.git

Install a package from a GitHub shorthand reference

$pnpm add github:user/repo

Install a package from a specific branch of a GitHub repository

$pnpm add github:user/repo#branch

Install a package from a local directory path

$pnpm add ./path/to/local-package

Install a local package using the file: protocol

$pnpm add file:./packages/my-lib

Install a package from a remote tarball URL

$pnpm add https://example.com/package.tgz

Remove Packages

Remove express from node_modules and package.json dependencies

$pnpm remove express

Remove typescript from node_modules and devDependencies

$pnpm remove typescript --save-dev

Remove lodash from node_modules and optionalDependencies

$pnpm remove lodash --save-optional

Remove a globally installed package

$pnpm remove -g typescript

Remove multiple packages simultaneously

$pnpm remove react react-dom

Update Packages

Update all packages to the latest version within their semver range

$pnpm update

Update express to the latest version within its semver range

$pnpm update express

Update all packages to the absolute latest version, ignoring semver ranges

$pnpm update --latest

Update express to the absolute latest version ignoring semver range

$pnpm update express --latest

Update only devDependencies within their semver ranges

$pnpm update --dev

Update only production dependencies within their semver ranges

$pnpm update --prod

Update all globally installed packages

$pnpm update --global

Update a specific globally installed package

$pnpm update --global typescript

Update packages in all workspace projects

$pnpm update --recursive

Update all packages to latest across all workspace projects

$pnpm update --recursive --latest

Interactively select which packages to update

$pnpm update --interactive

Interactively select packages to update to their latest versions

$pnpm update --interactive --latest

Scripts & Execution

Execute the build script defined in package.json

$pnpm run build

Execute the dev script defined in package.json

$pnpm run dev

Execute the test script defined in package.json

$pnpm run test

Execute the lint script defined in package.json

$pnpm run lint

Execute the start script defined in package.json

$pnpm run start

Run the start script shorthand

$pnpm start

Run the test script shorthand

$pnpm test

Run the build script shorthand if no pnpm subcommand conflicts

$pnpm build

Pass additional arguments to a script after the double-dash separator

$pnpm run build -- --watch

Run the build script only if it exists, without erroring if absent

$pnpm run build --if-present

Run the test script in all workspace packages in parallel

$pnpm run --parallel test

Run the build script in workspaces and stream output with package prefix

$pnpm run --stream build

Run the build script in all workspace packages sequentially

$pnpm run --sequential build

Run the build script only in a specific filtered workspace package

$pnpm run --filter @myorg/app build

Execute a locally installed binary from node_modules/.bin

$pnpm exec tsc

Execute a local binary with additional arguments

$pnpm exec -- tsc --init

Fetch and execute a package binary without installing it permanently

$pnpm dlx create-react-app my-app

Specify the package to fetch and then run its binary

$pnpm dlx --package=typescript tsc --init

Fetch and run a specific version of a package binary

$pnpm dlx create-next-app@latest my-app

Workspaces

Install dependencies for all packages in the workspace

$pnpm install --recursive

Add a dependency to a specific filtered workspace package

$pnpm add lodash --filter @myorg/app

Add a dependency referencing another package within the workspace

$pnpm add lodash --workspace

Run the build script in all workspace packages respecting dependency order

$pnpm run build --recursive

Run the build script in a specific workspace package

$pnpm run build --filter @myorg/app

Run build in a package and all packages that depend on it

$pnpm run build --filter @myorg/app...

Run build in a package and all its dependencies

$pnpm run build --filter ...@myorg/app

Run test script in all packages matching a glob path pattern

$pnpm run test --filter ./packages/**

Run test in all scoped packages in parallel

$pnpm run test --filter @myorg/* --parallel

Run build in all packages within a specific directory using brace glob

$pnpm run build --filter {packages/**}

Run build only in packages changed since the origin/main branch

$pnpm run build --filter "[origin/main]"

List installed packages across all workspace projects

$pnpm list --recursive

Check for outdated packages across all workspace projects

$pnpm outdated --recursive

Publish all changed workspace packages to the registry

$pnpm publish --recursive

Execute a binary in all workspace packages

$pnpm exec --recursive -- tsc --noEmit

Publish & Registry

Publish the current package to the npm registry

$pnpm publish

Publish a scoped package publicly to the npm registry

$pnpm publish --access public

Publish a package as restricted (private)

$pnpm publish --access restricted

Publish the package under a custom dist-tag instead of latest

$pnpm publish --tag beta

Simulate publishing without uploading anything to the registry

$pnpm publish --dry-run

Publish using a one-time password for 2FA-enabled accounts

$pnpm publish --otp 123456

Publish without verifying a clean git state or branch

$pnpm publish --no-git-checks

Publish all workspace packages that have changed

$pnpm publish --recursive

Create a .tgz tarball of the current package without publishing

$pnpm pack

List files that would be included in the tarball without creating it

$pnpm pack --dry-run

Authentication

Log in to the npm registry interactively

$pnpm login

Log in to a specific npm registry

$pnpm login --registry https://registry.npmjs.org/

Associate a scope with a specific registry and log in

$pnpm login --scope=@myorg

Log out from the npm registry, removing stored auth tokens

$pnpm logout

Log out from a specific registry

$pnpm logout --registry https://registry.npmjs.org/

Display the currently authenticated npm username

$pnpm whoami

Display the authenticated username for a specific registry

$pnpm whoami --registry https://registry.npmjs.org/

Listing & Dependency Tree

List installed packages and their dependency tree in the current project

$pnpm list

List only top-level installed packages without sub-dependencies

$pnpm list --depth=0

List installed packages up to one level of sub-dependencies

$pnpm list --depth=1

Output the installed dependency tree in JSON format

$pnpm list --json

List only production dependencies in the tree

$pnpm list --prod

List only development dependencies in the tree

$pnpm list --dev

Check if express is installed and show its resolved version

$pnpm list express

List all globally installed packages

$pnpm list --global

List top-level globally installed packages only

$pnpm list --global --depth=0

List packages across all workspace projects

$pnpm list --recursive

List top-level packages across all workspace projects

$pnpm list --recursive --depth=0

Explain why express is installed and which packages depend on it

$pnpm why express

Explain why express is installed across all workspace projects

$pnpm why express --recursive

Output the dependency explanation for express as JSON

$pnpm why express --json

Audit & Security

Scan installed dependencies for known security vulnerabilities

$pnpm audit

Output vulnerability audit results as JSON

$pnpm audit --json

Audit only production dependencies for vulnerabilities

$pnpm audit --prod

Audit only devDependencies for vulnerabilities

$pnpm audit --dev

Exit with error only if critical severity vulnerabilities are found

$pnpm audit --audit-level=critical

Exit with error if high or critical severity vulnerabilities are found

$pnpm audit --audit-level=high

Exit with error if moderate or higher severity vulnerabilities are found

$pnpm audit --audit-level=moderate

Automatically fix vulnerabilities by updating affected packages

$pnpm audit fix

Force fix vulnerabilities even if it requires breaking semver changes

$pnpm audit fix --force

Versioning

Increment the patch version in package.json and create a git tag

$pnpm version patch

Increment the minor version in package.json and create a git tag

$pnpm version minor

Increment the major version in package.json and create a git tag

$pnpm version major

Increment to the next prepatch prerelease version

$pnpm version prepatch

Increment to the next preminor prerelease version

$pnpm version preminor

Increment to the next premajor prerelease version

$pnpm version premajor

Increment the prerelease number of the current version

$pnpm version prerelease

Increment the prerelease version with a custom alpha identifier

$pnpm version prerelease --preid=alpha

Increment the prerelease version with a custom beta identifier

$pnpm version prerelease --preid=beta

Set an explicit version number in package.json

$pnpm version 2.0.0

Increment patch version without creating a git commit or tag

$pnpm version patch --no-git-tag-version

Increment patch version with a custom git commit message

$pnpm version patch -m "chore: release v%s"

Store Management

Print the path to the current pnpm content-addressable store

$pnpm store path

Check the integrity of packages currently in the store

$pnpm store status

Add a package to the store without linking it to any project

$pnpm store add express

Add a specific version of a package to the store

$pnpm store add express@4.18.2

Remove unreferenced packages from the content-addressable store

$pnpm store prune

Outdated

Check which installed packages have newer versions available

$pnpm outdated

Output outdated package information as JSON

$pnpm outdated --json

Show extended information including package links in outdated output

$pnpm outdated --long

Check outdated status for devDependencies only

$pnpm outdated --dev

Check outdated status for production dependencies only

$pnpm outdated --prod

Check for outdated globally installed packages

$pnpm outdated --global

Check for outdated packages across all workspace projects

$pnpm outdated --recursive

Linking

Create a global symlink for the current package for local development

$pnpm link --global

Link a globally registered package into the current project

$pnpm link --global my-package

Link a local directory as a dependency in the current project

$pnpm link ./path/to/local-package

Remove all symlinks created for the current project

$pnpm unlink

Remove a globally linked package

$pnpm unlink --global my-package

Patching

Prepare a package for patching by extracting it to a temporary directory

$pnpm patch express

Prepare a specific version of a package for patching

$pnpm patch express@4.18.2

Generate and save a patch file from a modified temporary package directory

$pnpm patch-commit /tmp/express

Remove a previously applied patch for a package

$pnpm patch-remove express

Miscellaneous

Print the path to the local node_modules directory

$pnpm root

Print the path to the global node_modules directory

$pnpm root --global

Print the path to the local .bin executables directory

$pnpm bin

Print the path to the global bin executables directory

$pnpm bin --global

Rebuild all native addons for the current Node.js version

$pnpm rebuild

Rebuild a specific native addon package

$pnpm rebuild bcrypt

Reduce duplication in the lockfile by resolving shared package versions

$pnpm dedupe

Check if deduplication is possible without modifying the lockfile

$pnpm dedupe --check

Remove extraneous packages from node_modules not in package.json

$pnpm prune

Remove devDependency packages from node_modules for production

$pnpm prune --prod

Display funding information for all installed packages

$pnpm fund

Run environment checks to verify pnpm is configured correctly

$pnpm doctor

Display the currently installed version of pnpm

$pnpm --version

Install and use the latest LTS version of Node.js globally via pnpm

$pnpm env use --global lts

Install and use Node.js version 20 globally via pnpm

$pnpm env use --global 20

Install and use the latest Node.js version globally via pnpm

$pnpm env use --global latest

List all Node.js versions installed via pnpm

$pnpm env list

List available Node.js versions from the remote registry

$pnpm env list --remote

Remove a specific Node.js version installed via pnpm

$pnpm env remove --global 18

List the licenses of all installed dependencies

$pnpm licenses list

Output license information for all installed dependencies as JSON

$pnpm licenses list --json