メインコンテンツまでスキップ
Version: Next

pnpm add <pkg>

パッケージとそれが依存しているすべてのパッケージをインストールします。 デフォルトでは、すべての新しいパッケージは production 依存として追加されます。

概要

コマンド意味
pnpm add saxdependencies へ保存
pnpm add -D saxdevDependencies へ保存
pnpm add -O saxoptionalDependencies へ保存
pnpm add -g saxグローバルにインストール
pnpm add sax@nextnext タグに対応するバージョンを保存
pnpm add sax@3.0.0バージョン 3.0.0 を指定

Supported package sources

pnpm supports installing packages from various sources. See the Supported package sources page for detailed documentation on:

  • npm registry
  • JSR registry
  • Workspace packages
  • Local file system (tarballs and directories)
  • Remote tarballs
  • Git repositories (with semver, subdirectories, and more)

オプション

--save-prod, -P

指定されたパッケージを通常の dependencies としてインストールします。

--save-dev, -D

指定されたパッケージを通常の devDependencies としてインストールします。

--save-optional, -O

指定されたパッケージを通常の optionalDependencies としてインストールします。

--save-exact, -E

pnpm のデフォルトの semver 範囲指定演算子を使用するのではなく、固定したバージョンで保存します。

--save-peer

--save-peer を使うことで、1つ以上の依存パッケージを peerDependenciesdevDependencies の両方に追加します。

--save-catalog

Added in: v10.12.1

Save the new dependency to the default catalog.

--save-catalog-name <catalog_name>

Added in: v10.12.1

Save the new dependency to the specified catalog.

--config

Added in: v10.8.0

Save the dependency to configDependencies.

--ignore-workspace-root-check

--ignore-workspace-root-check または -w フラグが使用されていない限り、新しい依存関係をワークスペースのルートに追加しようとすると失敗します。

例: pnpm add debug -w

--global, -g

パッケージをグローバルにインストールします。

--workspace

ワークスペースで見つかった場合にのみ、新しい依存関係を追加します。

--allow-build

追加されたバージョン:v10.4.0

インストール中に postinstall スクリプトを実行することを許可するパッケージのリスト。

例:

pnpm --allow-build=esbuild add my-bundler

This will run esbuild's postinstall script and also add it to the onlyBuiltDependencies field of pnpm-workspace.yaml. したがって、esbuild は今後も常にスクリプトの実行を許可されるようになります。

--filter <package_selector>

詳細についてはフィルタリングに関するドキュメントを参照してください。

--cpu=<name>

Added in: v10.14.0

Override CPU architecture of native modules to install. Acceptable values are same as cpu field of package.json, which comes from process.arch.

--os=<name>

Added in: v10.14.0

Override OS of native modules to install. Acceptable values are same as os field of package.json, which comes from process.platform.

--libc=<name>

Added in: v10.14.0

Override libc of native modules to install. Acceptable values are same as libc field of package.json.