Publish and restore npm packages from the command line

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

Using Azure Artifacts, you can easily manage the publication and retrieval of npm packages from various sources, including feeds and public registries like npmjs.com. This article will walk you through setting up your project, and publishing and restoring your npm packages from your Azure Artifacts feed.

Prerequisites

Connect to feed

  1. Sign in to your Azure DevOps organization, and then navigate to your project.

  2. Select Artifacts, and then select your feed from the dropdown menu.

  3. Select Connect to feed, and then select npm from the left.

  4. In the Project setup section, choose Windows if your operating system is Windows; otherwise, select Other. Follow the provided instructions to configure your .npmrc file and connect to your feed. If this is the first time using Azure Artifacts with npm, make sure you Get the tools at the top right corner of the page.

    A screenshot showing how to connect to your feed.

Publish packages

Run the following command in your project directory to publish the npm packages listed in your package.json:

npm publish

Restore packages

Run the following command in your project directory to restore all your npm packages:

npm install

If you want to restore a specific package, run the following command in your project directory:

npm install --save <PACKAGE_NAME>