Uredi

Deli z drugimi prek


Npm@1 - npm v1 task

Use this task to install and publish npm packages or to run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.

Note

The npm Authenticate task is the recommended way to authenticate with Azure Artifacts. This task no longer takes new features and only critical bugs are addressed.

Syntax

# 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 && command = install || command = ci || command = publish. 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 customRegistry = useFeed && command = install || command = ci || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = ci || command = custom. 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.
# 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' # '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 = publish. Verbose logging. 
    #publishPackageMetadata: true # boolean. Optional. Use when command = publish && publishRegistry = useFeed && command = install || command = publish. Publish pipeline metadata. Default: true.
  # Custom registries and authentication
    #customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = custom. Registries to use. Default: useNpmrc.
    #customFeed: # string. Required when customRegistry = useFeed && command = install || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom. 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.
# npm v1
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
- task: Npm@1
  inputs:
    command: 'install' # 'install' | 'publish' | 'custom'. Required. Command. Default: install.
    #workingDir: # string. Working folder with package.json. 
    #customCommand: # string. Required when command = custom. Command and arguments. 
  # Advanced
    #verbose: # boolean. Optional. Use when command = install || command = publish. Verbose logging. 
  # Custom registries and authentication
    #customRegistry: 'useNpmrc' # 'useNpmrc' | 'useFeed'. Optional. Use when command = install || command = custom. Registries to use. Default: useNpmrc.
    #customFeed: # string. Required when customRegistry = useFeed && command = install || command = custom. Use packages from this Azure Artifacts/TFS registry. 
    #customEndpoint: # string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom. Credentials for registries outside this account/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.

Inputs

command - Command
string. Required. Allowed values: ci, install, publish, custom. Default value: install.

Specifies the command and arguments, which are passed to npm for execution.

If your arguments contain double quotes ("), escape them with a slash (\), and surround the escaped string with double quotes (").


command - Command
string. Required. Allowed values: install, publish, custom. Default value: install.

Specifies the command and arguments, which are passed to npm for execution.

If your arguments contain double quotes ("), escape them with a slash (\), and surround the escaped string with double quotes (").


workingDir - Working folder that contains package.json
string.

Specifies the path to the folder containing the target package.json and .npmrc files. Select the folder, not the file. Example: /packages/mypackage.


workingDir - Working folder with package.json
string.

Specifies the path to the folder containing the target package.json and .npmrc files. Select the folder, not the file. Example: /packages/mypackage.


verbose - Verbose logging
boolean. Optional. Use when command = install || command = ci || command = publish.

Prints more information to the console when the task runs.


verbose - Verbose logging
boolean. Optional. Use when command = install || command = publish.

Prints more information to the console when the task runs.


customCommand - Command and arguments
string. Required when command = custom.

Runs a custom command. Example: dist-tag ls mypackage.


customRegistry - Registries to use
string. Optional. Use when command = install || command = ci || command = custom. Allowed values: useNpmrc (Registries in my .npmrc), useFeed (Registry I select here). Default value: useNpmrc.

Specifies the registries to use. Commit a .npmrc file to your source code repository and set its path as the value, or specify a registry from Azure Artifacts as the value.


customRegistry - Registries to use
string. Optional. Use when command = install || command = custom. Allowed values: useNpmrc (Registries in my .npmrc), useFeed (Registry I select here). Default value: useNpmrc.

Specifies the registries to use. Commit a .npmrc file to your source code repository and set its path as the value, or specify a registry from Azure Artifacts as the value.


customFeed - Use packages from this Azure Artifacts/TFS registry
string. Required when customRegistry = useFeed && command = install || command = ci || command = custom.

Includes the selected feed in the generated .npmrc. For project-scoped feeds, use ProjectName/FeedName or ProjectID/FeedID. For organization-scoped feeds, the value should be the feed name.


customFeed - Use packages from this Azure Artifacts/TFS registry
string. Required when customRegistry = useFeed && command = install || command = custom.

Includes the selected feed in the generated .npmrc. For project-scoped feeds, use ProjectName/FeedName or ProjectID/FeedID. For organization-scoped feeds, the value should be the feed name.


customEndpoint - Credentials for registries outside this organization/collection
string. Optional. Use when customRegistry = useNpmrc && command = install || command = ci || command = custom.

Credentials to use for external registries located in the project's .npmrc. Leave this blank for registries in this account/collection; the task uses the build's credentials automatically.


customEndpoint - Credentials for registries outside this organization/collection
string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom.

Credentials to use for external registries located in the project's .npmrc. Leave this blank for registries in this account/collection; the task uses the build's credentials automatically.


customEndpoint - Credentials for registries outside this account/collection
string. Optional. Use when customRegistry = useNpmrc && command = install || command = custom.

Credentials to use for external registries located in the project's .npmrc. Leave this blank for registries in this account/collection; the task uses the build's credentials automatically.


publishRegistry - Registry location
string. Optional. Use when command = publish. Allowed values: useExternalRegistry (External npm registry (including other accounts/collections)), useFeed (Registry I select here). Default value: useExternalRegistry.

Specifies the registry that the command will target.


publishFeed - Target registry
string. Required when publishRegistry = useFeed && command = publish.

Specifies a registry hosted in the account. You must have Package Management installed and licensed to select a registry here.


publishPackageMetadata - Publish pipeline metadata
boolean. Optional. Use when command = publish && publishRegistry = useFeed && command = install || command = ci || command = publish. Default value: true.

Associates the build/release pipeline's metadata (the run # and source code information) with the package.


publishPackageMetadata - Publish pipeline metadata
boolean. Optional. Use when command = publish && publishRegistry = useFeed && command = install || command = publish. Default value: true.

Associates the build/release pipeline's metadata (the run # and source code information) with the package.


publishEndpoint - External Registry
string. Required when publishRegistry = useExternalRegistry && command = publish.

Specifies the credentials to use for publishing to an external registry.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Note

The Project Collection Build Service and your project's Build Service identity must be set to Contributor to publish your packages to a feed using Azure Pipelines. See Add new users/groups for more details.

Where can I learn npm commands and arguments?

Examples

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: npm
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.115.0 or greater
Task category Package
Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: npm
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 1.91.0 or greater
Task category Package