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

npm との違い#

npm とは異なり、pnpm はすべてのオプションを検証します。例えば、 pnpm install --foo は --foo が不正なオプションであるため、 pnpm install は失敗します。

ただし、一部の依存パッケージは、CLI のオプションから設定される npm_config_ 環境変数を使用することがあります。この場合、次の選択肢があります。

  1. 明示的に環境変数を設定: npm_config_foo=true pnpm install
  2. 不明なオプションを config で強制: pnpm install --config.target_arch=x64

オプション#

-C <path>, --dir <path>#

現在の作業ディレクトリの代わりに <path> でpnpm が起動されたかのように実行します。

-w, --workspace-root#

Run as if pnpm was started in the root of the workspace instead of the current working directory.

コマンド#

詳細については、個別の CLI コマンドのドキュメントを参照してください。以下は、簡単な npm との対応表です。

npm のコマンドpnpm で同等のコマンド
npm installpnpm install
npm i <pkg>[pnpm add <pkg>]
npm run <cmd>[pnpm <cmd>]
npx <pkg>[pnx <pkg>]

未知のコマンドが使用されると、pnpm は指定されたコマンドと同じ名前を持つスクリプトを検索します。例えば、 pnpm run lint は 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).

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_HOME
  • XDG_CONFIG_HOME
  • XDG_DATA_HOME
  • XDG_STATE_HOME

You can search the docs to find the settings that leverage these environment variables.