Publish npm packages (YAML/Classic)

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

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'll 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 Feed Publisher (Contributor) to publish your packages to a feed using Azure Pipelines. For more information, see Add new users/groups.

- task: Npm@1
  inputs:
    command: publish
    publishRegistry: useFeed
    publishFeed: <FEED_NAME>        ## For project-scoped feeds, use: <PROJECT_NAME>/<FEED_NAME> 
  • publishRegistry: Options: useExternalRegistry, useFeed. Select useFeed to use a feed within your organization.
  • publishFeed: Required when publishRegistry = useFeed. The feed you want to publish to.

Tip

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

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're 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.