このタスクを使用して、npm パッケージをインストールして発行するか、npm コマンドを実行します。 Azure Artifacts などの npmjs.com および認証済みレジストリをサポートします。
注
Azure Artifacts フィードで認証するには、 npm 認証 タスクを使用します。
Npm@1 タスクは現在開発中ではなく、重大なバグのみが対処されます。
構文
# npm v1
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
- task: Npm@1
inputs:
command: 'install' # 'ci' | 'install' | 'publish' | 'custom'. Required. Command. Default: install.
#workingDir: # string. Working folder that contains package.json.
#customCommand: # string. Required when command = custom. Command and arguments.
# Advanced
#verbose: # boolean. Optional. Use when command = install || command = ci || command = publish. Verbose logging.
#publishPackageMetadata: true # boolean. Optional. Use when command = publish && publishRegistry = useFeed. Publish pipeline metadata. Default: true.
# Custom registries and authentication
#customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = ci || command = custom. Registries to use. Default: useNpmrc.
#customFeed: # string. Required when (command = install || command = ci || command = custom) && customRegistry = useFeed. Use packages from this Azure Artifacts/TFS registry.
#customEndpoint: # string. Optional. Use when (command = install || command = ci || command = custom) && customRegistry = useNpmrc. Credentials for registries outside this organization/collection.
# Destination registry and authentication
#publishRegistry: 'useExternalRegistry' # 'useExternalRegistry' | 'useFeed'. Optional. Use when command = publish. Registry ___location. Default: useExternalRegistry.
#publishFeed: # string. Required when publishRegistry = useFeed && command = publish. Target registry.
#publishEndpoint: # string. Required when publishRegistry = useExternalRegistry && command = publish. External Registry.
入力
command
-
コマンド
string。 必須。 使用できる値: ci、install、publish、custom。 既定値: install.
実行のために npm に渡されるコマンドと引数を指定します。
引数に二重引用符 (") が含まれている場合は、スラッシュ (\) でエスケープし、エスケープされた文字列を二重引用符 (") で囲みます。
既定では、パッケージはローカルにインストールされます。 パッケージをグローバルにインストールするには、コマンドとして install -g を指定します。 詳細については、「パッケージをグローバルにダウンロードしてインストールする」を し、パッケージをローカルにダウンロードしてインストール を参照してください。
package.jsonを含む作業フォルダーを workingDir - する
string。
ターゲット package.json と .npmrc ファイルを含むフォルダーへのパスを指定します。 ファイルではなく、フォルダーを選択します。 例: /packages/mypackage。
詳細ログの verbose -
boolean。 任意
command = install || command = ci || command = publishするときに使用します。
タスクの実行時に、コンソールに詳細情報を出力します。
customCommand
-
コマンドと引数の
string。
command = customする場合に必要です。
カスタム コマンドを実行します。 例: dist-tag ls mypackage。
を使用するレジストリの customRegistry -
string。 任意
command = install || command = ci || command = customするときに使用します。 使用できる値: useNpmrc (.npmrc のレジストリ)、useFeed (ここで選択したレジストリ)。 既定値: useNpmrc.
使用するレジストリを指定します。
.npmrc ファイルをソース コード リポジトリにコミットし、そのパスを値として設定するか、Azure Artifacts のレジストリを値として指定します。
customFeed
-
この Azure Artifacts/TFS レジストリ のパッケージを使用する
string。
(command = install || command = ci || command = custom) && customRegistry = useFeedする場合に必要です。
選択したフィードを生成された .npmrcに含めます。 プロジェクト スコープフィードの場合は、ProjectName/FeedName または ProjectID/FeedIDを使用します。 組織スコープのフィードの場合、値はフィード名にする必要があります。
この組織またはコレクションの外のレジストリの customEndpoint - 資格情報
string。 任意
(command = install || command = ci || command = custom) && customRegistry = useNpmrcするときに使用します。
プロジェクトの .npmrcにある外部レジストリに使用する資格情報。 このアカウント/コレクション内のレジストリの場合は、この値を空白のままにします。タスクはビルドの資格情報を自動的に使用します。
publishRegistry
-
レジストリの場所
string。 任意
command = publishするときに使用します。 使用できる値: useExternalRegistry (外部 npm レジストリ (他のアカウント/コレクションを含む)))、useFeed (ここで選択したレジストリ)。 既定値: useExternalRegistry.
コマンドの対象となるレジストリを指定します。
publishFeed
-
ターゲット レジストリの
string。
publishRegistry = useFeed && command = publishする場合に必要です。
アカウントでホストされているレジストリを指定します。 ここでレジストリを選択するには、パッケージ管理がインストールされ、ライセンスが付与されている必要があります。
publishPackageMetadata
-
パイプライン メタデータ を発行する
boolean。 任意
command = publish && publishRegistry = useFeedするときに使用します。 既定値: true.
ビルド/リリース パイプラインのメタデータ (実行 # とソース コード情報) をパッケージに関連付けます。
外部レジストリの publishEndpoint -
string。
publishRegistry = useExternalRegistry && command = publishする場合に必要です。
外部レジストリへの発行に使用する資格情報を指定します。
タスク コントロールのオプション
すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。
出力変数
なし。
注釈
注
Project Collection Build Service とプロジェクトの Build Service ID は、Azure Pipelines を使用してパッケージをフィードに発行するために、共同作成者 設定する必要があります。 詳細については、「新しいユーザー/グループ を追加する」を参照してください。