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.
From within your pipeline, select the + sign to add a task to your pipeline, then search for the npm task. Select Add to add it to your pipeline.
Name your task and select Publish from the dropdown menu. Select your package.json path, your Registry location and your Target registry
Working folder that contains package.json: path to the folder containing the target package.json and .npmrc files. Leave this blank if those files are at the root of your repo.
Registry location: select Registry I select here to publish to an Azure Artifacts feed. select your feed from the dropdown menu.
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.
Select Project settings, and then select Service connections.
Select Create service connection to create a new service connection.
Select npm and then select Next. Fill out the required fields, and then select Save when you are done.
From within your pipeline, select the + sign to add a task to your pipeline, then search for the npm task. Select Add to add it to your pipeline.
Name your task, and then select Publish from the dropdown menu. Select your package.json path, your Registry location and your External registry.
Working folder that contains package.json: path to the folder containing the target package.json and .npmrc files. Leave this blank if those files are at the root of your repo.
Registry location: select External npm registry to publish to public registries such as npmjs.com. Enter the name of the service connection you created earlier.