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.

Inputs

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 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 = 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 = 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 VSTS/TFS registry
string. Required when customRegistry = useFeed && command = install || command = custom.

Includes the selected feed in the generated .npmrc. You must have Azure Artifacts installed and licensed to select a feed here. 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 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.


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 1.91.0 or greater
Task category Package