pnpm add: Usage, Options & Common Errors
Add a dependency to a package or the workspace root.
pnpm add installs packages and records them in package.json, updating pnpm-lock.yaml - with workspace-aware flags for monorepos.
What it does
Resolves and links the requested packages and saves them to dependencies (or devDependencies with -D). -w adds to the workspace root manifest; --filter <pkg> targets a specific workspace package. Use -E for an exact version.
Common usage
Terminal
pnpm add lodash # runtime dependency
pnpm add -D typescript # devDependency
pnpm add -w prettier # add to the workspace root
pnpm add --filter @acme/web reactCommon CI error: ERR_PNPM_FETCH_404
pnpm add fails with "ERR_PNPM_FETCH_404 / GET ... 404 Not Found". The package name is wrong, or it is private and the registry/auth is not configured. Verify the name, and set the registry and auth token (.npmrc) for private scopes before adding.
.npmrc
# private scope auth in .npmrc:
//registry.acme.dev/:_authToken=${NPM_TOKEN}
@acme:registry=https://registry.acme.dev/Related guides
pnpm ERR_PNPM_FETCH_404 - Fix "GET … 404" Package Fetch in CIFix pnpm ERR_PNPM_FETCH_404 "GET https://…: Not Found - 404" in CI - a package or version pnpm cannot fetch f…
pnpm ERR_PNPM_NO_MATCHING_VERSION "No matching version found" - Fix in CIFix pnpm ERR_PNPM_NO_MATCHING_VERSION "No matching version found for <pkg>@<range>" in CI - a range no publis…
pnpm install: Usage, Options & Common CI Errorspnpm install resolves dependencies into the content-addressable store and links node_modules. Usage, --frozen…