Skip to content
Latchkey

pnpm add: Add Dependencies

pnpm add installs a package and updates the manifest.

pnpm add supports monorepo targeting with --filter, but like other add commands it belongs in PRs, not CI.

Common flags

  • -D - devDependency
  • -E - exact version
  • --filter <pkg> - add to one workspace
  • -w - add to the workspace root

Example

Add a dev tool to one workspace package.

shell
pnpm add -D -E --filter @app/web vitest

In CI

Running pnpm add in CI mutates the lockfile and breaks --frozen-lockfile. Keep it to local development.

Key takeaways

  • --filter targets a workspace.
  • -w adds to the root.
  • Do not run pnpm add in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →