Movatterモバイル変換


[0]ホーム

URL:


メインコンテンツまでスキップ
Version: 10.x

pnpm add <pkg>

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

TL;DR

コマンド意味
pnpm add saxSave todependencies
pnpm add -D saxSave todevDependencies
pnpm add -O saxSave tooptionalDependencies
pnpm add -g saxグローバルにインストール
pnpm add sax@nextInstall from thenext tag
pnpm add sax@3.0.0Specify version3.0.0

サポートされているパッケージの取得先

npm レジストリからインストール

pnpm add package-name will install the latest version ofpackage-name fromthenpm registry by default.

ワークスペースで実行された場合、最初に他のプロジェクトが指定された依存パッケージを使用しているかどうかを確認しようとします。 その場合、すでに使用されているバージョン範囲がインストールされます。

また、次のようにパッケージをインストールすることも可能です。

  • tag:pnpm add express@nightly
  • version:pnpm add express@1.0.0
  • version range:pnpm add express@2 react@">=0.1.0 <0.2.0"

ワークスペースからインストール

Note that when adding dependencies and working within aworkspace, packageswill be installed from the configured sources, depending on whether or notlink-workspace-packages is set, and use of theworkspace: range protocol.

ローカルファイルシステムからインストール

ローカルファイルシステムからインストールする方法は2つあります。

  1. from a tarball file (.tar,.tar.gz, or.tgz)
  2. ディレクトリから

例:

pnpm add ./package.tar.gz
pnpm add ./some-directory

When you install from a directory, a symlink will be created in the currentproject'snode_modules, so it is the same as runningpnpm link.

リモートの tarball からインストール

引数は、 "http://" または "https://" で始まるフェッチ可能な URL でなければなりません。

例:

pnpm add https://github.com/indexzero/forever/tarball/v0.5.6

Git リポジトリからインストール

pnpm add <git remote url>

ホストされた Git プロバイダからパッケージを Git でクローンしてインストールします。

Gitからパッケージをインストールするには、以下の方法があります。

  • デフォルトブランチの最新コミット:
pnpm add kevva/is-positive
  • Git コミットハッシュ:
pnpm add kevva/is-positive#97edff6f525f192a3f83cea1944765f769ae2678
  • Git ブランチ:
pnpm add kevva/is-positive#master
  • refs に対する相対的な Git ブランチ:
pnpm add zkochan/is-negative#heads/canary
  • Git タグ:
pnpm add zkochan/is-negative#2.0.1
  • v で始まる Git タグ:
pnpm add andreineculau/npm-publish-git#v0.0.7

semver を使用して Git リポジトリからインストールする

You can specify version (range) to install using thesemver: parameter. 例:

  • 厳密な semver:
pnpm add zkochan/is-negative#semver:1.0.0
  • v で始まる厳密な semver:
pnpm add andreineculau/npm-publish-git#semver:v0.0.7
  • semver バージョン範囲:
pnpm add kevva/is-positive#semver:^2.0.0
  • v で始まる semver バージョン範囲:
pnpm add andreineculau/npm-publish-git#semver:<=v0.0.7

Git リポジトリのサブディレクトリからインストールする

You may also install just a subdirectory from a Git-hosted monorepo using thepath: parameter. 例:

pnpm add RexSkz/test-git-subdir-fetch#path:/packages/simple-react-app

完全な URL 経由で Git リポジトリからインストールする

もっと明確にしたい場合や、別の Git ホスティングを使用している場合は、完全な Git URL を明記することをおすすめします。

# git+ssh
pnpm add git+ssh://git@github.com:zkochan/is-negative.git#2.0.1

# https
pnpm add https://github.com/zkochan/is-negative.git#2.0.1

ホスティングプロバイダーのショートカットを使用して、Git リポジトリからインストールする

You can use a protocol shorthand[provider]: for certain Git providers:

pnpm add github:zkochan/is-negative
pnpm add bitbucket:pnpmjs/git-resolver
pnpm add gitlab:pnpm/git-resolver

If[provider]: is omitted, it defaults togithub:.

さまざまなパラメータを組み合わせて Git リポジトリからインストールする

It is possible to combine multiple parameters by separating them with&. これはモノレポのフォークで便利です:

pnpm add RexSkz/test-git-subdir-fetch.git#beta\&path:/packages/simple-react-app

Installs from thebeta branch and only the subdirectory at/packages/simple-react-app.

Options

--save-prod, -P

Install the specified packages as regulardependencies.

--save-dev, -D

Install the specified packages asdevDependencies.

--save-optional, -O

Install the specified packages asoptionalDependencies.

--save-exact, -E

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

--save-peer

Using--save-peer will add one or more packages topeerDependencies andinstall them as dev dependencies.

--ignore-workspace-root-check

Adding a new dependency to the root workspace package fails, unless the--ignore-workspace-root-check or-w flag is used.

For instance,pnpm add debug -w.

--global, -g

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

--workspace

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

--allow-build

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

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

例:

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

This will runesbuild's postinstall script and also add it to thepnpm.onlyBuiltDependencies field ofpackage.json. So,esbuild will always be allowed to run its scripts in the future.

--filter <package_selector>

Read more about filtering.


[8]ページ先頭

©2009-2025 Movatter.jp