Get started with npm packages in Azure Artifacts

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

Using Azure Artifacts, you can publish and download your npm packages from feeds and public registries such as npmjs.com. This quickstart will guide you through creating your feed, configuring your project, and managing npm packages with your Azure Artifacts feed.

Prerequisites

Create a feed

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

  2. Select Artifacts, and then select Create Feed to create a new feed.

  3. Enter a descriptive Name for your feed and define its Visibility (indicating who can view packages within the feed). Specify the Scope of your feed, and if you wish to include packages from public sources, mark the Upstream sources checkbox.

  4. Select Create when you're done.

    A screenshot showing how to create a new feed in Azure DevOps Services.

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

  2. Select Artifacts, and then select Create Feed to create a new feed.

  3. Enter a descriptive Name for your feed and define its Visibility (indicating who can view packages within the feed). Specify the Scope of your feed, and if you wish to include packages from public sources, mark the Upstream sources checkbox.

  1. Select Create when you're done.

    A screenshot showing how to create a new feed in Azure DevOps 2022.

  1. Select Create when you're done.

    A screenshot showing how to create a new feed in Azure DevOps 2020.

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

  2. Select Artifacts, and then select New feed.

  3. Enter a descriptive Name for your feed and define its Visibility (indicating who can view packages within the feed). If you wish to include packages from public sources, select the Use packages from public sources through this feed option.

  4. Select Create when you're done.

    A screenshot showing how to create a new feed in Azure DevOps 2019.

Note

By default, newly created feeds have their project's Build Service set to Feed and Upstream Reader (Collaborator).

Connect to a feed

Note

vsts-npm-auth is not supported in Azure DevOps Server.

Azure Artifacts recommends using two .npmrc files. The first one should be placed in the $home directory (Linux/macOS) or $env.HOME (Windows) to securely store your credentials. This allows the npm client to locate the file and retrieve your credentials for authentication, enabling you to share your config file without exposing your credentials. In this section, we will set up the second .npmrc file, which should be placed in the same directory as your package.json file.

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

  2. Select Artifacts, and then select Connect to feed.

  3. Select npm from the left navigation area. If this is your first time using Azure Artifacts with npm, make sure you've installed the prerequisites.

  4. Follow the instructions in the Project setup section to set up your config file and connect to your feed.

    A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Services.

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

  2. Select Artifacts, and then select Connect to Feed.

  3. Select npm from the left, and then follow the instructions in the Project setup section to connect to your feed.

    A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2022.

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

  2. Select Artifacts, and then select Connect to feed.

  3. Select npm from the left, and then follow the instructions in Project setup to set up your config file and connect to your feed.

    A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2020.

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

  2. Select Artifacts, and then select Connect to feed.

  3. A new window will appear. From the left navigation pane, select npm and follow the instructions to set up your project and user .npmrc files.

    A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2019.

Important

npm supports a single registry in your .npmrc file. Multiple registries are possible with scopes and upstream sources.

Publish packages

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

npm publish

Important

Using the publishConfig property to override the registry config param at publish-time is not supported.

Restore packages

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

npm install

To restore a specific npm package, run the following command from your project directory:

npm install --save <PACKAGE_NAME>