Publish npm packages (YAML/Classic)

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018

Using Azure Pipelines, you can publish your npm packages to Azure Artifacts feeds or to public registries such as npmjs.com. In this article, you will learn how to publish your npm packages using YAML and Classic pipelines.

Publish to Azure Artifacts feeds

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.

- task: Npm@1
  inputs:
    command: publish
    publishRegistry: useFeed
    publishFeed: <PROJECT_NAME>/<FEED_NAME>
  • publishRegistry: Select useFeed to use a feed in the same organization as your build. Options: useFeed | useExternalRegistry.
  • publishFeed: Target registry. Required when publishRegistry = useFeed.

[TIP] Using the YAML editor to add the npm publish task will generate the project and feed IDs for your publishFeed.

YAML is not supported in TFS.

Publish to a public registry

To publish your packages to a public npm registry such as npmjs.com, you must first create a service connection to connect to the desired external service.

  1. Select Project settings, and then select Service connections.

  2. Select Create service connection to create a new service connection.

    Screenshot showing how to create a new service connection

  3. Select npm and then select Next. Fill out the required fields, and then select Save when you are done.

- task: Npm@1
  inputs:
    command: publish
    publishRegistry: useExternalRegistry
    publishEndpoint: '<NAME_OF_YOUR_SERVICE_CONNECTION>'
  • publishRegistry: Select useExternalRegistry to publish to a public registry. Options: useExternalRegistry | useFeed.
  • publishEndpoint: required when publishRegistry == useExternalRegistry. Replace the placeholder with the name of the service connection you created earlier.

YAML is not supported in TFS.