Part of pnpm/tasks#191. Wrong claims: - npmrc: `ca` defaults to the system trust store (v12) or the Node.js CA set (v11), not "the npm CA certificate". - pnpm-cli: `--config.<key>` does not populate `npm_config_*` for scripts (v11 and v12). - pnpm-vs-npm, package-sources: `file:` directories are copied into the virtual store and installed; only `link:` is a symlink. - pnpmfile: `importPackage` is removed in v12; changing the pnpmfile re-resolves, so the lockfile need not be deleted (v11 and v12). - scripts: list every environment variable a script receives (v11 and v12), and the full set of built-ins a script can shadow. - supply-chain-security: build scripts are blocked by `allowBuilds` and `strictDepBuilds`, and `blockExoticSubdeps` is on by default. - workspaces: pnpm has built-in release management (v11 and v12). Missing: - npmrc: `NODE_EXTRA_CA_CERTS`. - pnpm-cli: `--workspace-packages`, `-y`, and the `NO_COLOR`, `pnpm_config_*`, `PNPM_HOME`, `PNPM_SHIM_BYPASS` variables. - package_json: a `packageManager` section, `@<scope>:registry` in the `publishConfig` list, the built-in injected-deps sync. - pnpmfile: `beforePacking(pkg, dir, context)`, TL;DR rows for `updateConfig`, `preResolution`, `finders`, the `.cjs` fallback. - typescript: `addMissingPeerTypes`; uninstall: cache, state, and config directories; scripts: project lifecycle stages; workspaces: a minimal `packages` example and live sync while a script runs. - sidebar: `only-allow-pnpm`, `production`, and `cli/cache`. Clarity and duplication: - One home for git-dependency preparation (package-managers), Python index rules (registries), finders (finders.md). - motivation, symlinked-node-modules-structure: files are hard-linked or cloned; package directories are real directories; Node resolves symlinks to real paths. - podman copies the lockfile and workspace manifest; webcontainers leads with `pmOnFail: ignore`; task priority applies within a concurrency group; logos get alt text; store-loader spells out CAS. - using-changesets workflow uses the same action versions and Node.js 24 as the CI guide (v11 and v12). Stale history on v12 pages: - Removed "Added in" markers for v11 and older, and rewrote "Since v11..." and pnpm 10/11 narration as current behavior. Review follow-up: the script environment notes say which npm_config_* keys are filtered (auth, scope registry, per-registry) and that pnpm sets npm_config_user_agent and npm_config_node_gyp; a string `bin` sets npm_package_bin; NODE_EXTRA_CA_CERTS adds to whichever CA set applies; the v10 codemod command notes pnpx; motivation notes that pnpm copies files when neither hard links nor clones work; production says `pnpm fetch` reads the lockfile, not the package manifests.
2.5 KiB
id, title
| id | title |
|---|---|
| pnpm-cli | pnpm CLI |
Short aliases
Added in: v11.0.0
pn is available as a short alias for pnpm, and pnx as a short alias for pnpm dlx. You can use them anywhere you'd use pnpm or pnpx:
pn install
pn add express
pn build
pn test
pnx create-vue my-app
Differences vs npm
Unlike npm, pnpm validates all options. For example, pnpm install --target_arch x64 will
fail as --target_arch is not a valid option for pnpm install.
Some dependencies read an npm_config_ environment variable during their build.
pnpm does not set these variables from its options, so set the variable yourself:
npm_config_target_arch=x64 pnpm install.
Options
-C <path>, --dir <path>
Run as if pnpm was started in <path> instead of the current working directory.
-w, --workspace-root
Run as if pnpm was started in the root of the workspace instead of the current working directory.
Commands
For more information, see the documentation for individual CLI commands. Here is a list of handy npm equivalents to get you started:
| npm command | pnpm equivalent |
|---|---|
npm install |
pnpm install |
npm i <pkg> |
pnpm add <pkg> |
npm run <cmd> |
pnpm <cmd> |
npx <pkg> |
pnx <pkg> |
When an unknown command is used, pnpm will search for a script with the given name,
so pnpm run lint is the same as pnpm lint. If there is no script with the specified name,
then pnpm will execute the command as a shell script, so you can do things like pnpm eslint (see pnpm exec).
Since v11.28.0, this also works with --filter and --recursive: pnpm -r eslint runs the eslint script in the selected projects that have one, and when none of them has a script by that name, it runs the eslint command installed in their dependencies. pnpm run with --filter or -r still reports the missing script.
Environment variables
Some environment variables that are not pnpm related might change the behaviour of pnpm:
These environment variables may influence what directories pnpm will use for storing global information:
XDG_CACHE_HOMEXDG_CONFIG_HOMEXDG_DATA_HOMEXDG_STATE_HOME
You can search the docs to find the settings that use these environment variables.