pnpm Install and Dependencies

Dependency types, package sources, versions, lockfiles, and reproducible installs.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Dependency Types
Add production dependency
pnpm add express

# Save package to dependencies.

Add development dependency
pnpm add -D vitest

# Save package to devDependencies.

Add optional dependency
pnpm add -O sharp

# Save package to optionalDependencies.

Add peer dependency entry
pnpm add -D react && pnpm pkg set peerDependencies.react='^18.0.0'

# Install for local development and declare the peer dependency in package.json.

Install package globally
pnpm add -g npm-check-updates

# Install a package globally.

## Versions and Sources
Install dist-tag
pnpm add react@next

# Install a package using a registry dist-tag.

Install exact version
pnpm add react@18.3.1

# Install a specific version.

Install version range
pnpm add react@^18

# Install a version range.

Install tarball URL
pnpm add https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz

# Install a package from a tarball URL.

Install from Git repo
pnpm add github:lodash/lodash

# Install a package directly from a Git-hosted repository.

Install local folder
pnpm add ./packages/utils

# Install from a local directory path.

Install workspace package via protocol
pnpm add @acme/ui@workspace:*

# Link a workspace package using the workspace protocol.

## Lockfiles and Reproducibility
Clean install from lockfile
pnpm ci

# Perform a clean install from an existing lockfile.

Prefer frozen lockfile
pnpm install --prefer-frozen-lockfile

# Prefer a frozen install but allow lockfile generation when needed.

Install without lockfile
pnpm install --no-lockfile

# Avoid generating or using a lockfile in temporary scenarios.

Check lockfile status in Git
git diff -- pnpm-lock.yaml

# Inspect lockfile changes after dependency operations.

Show outdated packages with details
pnpm outdated --long

# Display richer outdated dependency information.

Recommended next

No recommendations yet.