Edit

Share via


Connect to an Azure Artifacts feed - npm

Azure DevOps Services | Azure DevOps Server 2022 | Azure DevOps Server 2020

Azure Artifacts enables developers to manage packages from various sources, including public registries like npmjs.com and private feeds. To authenticate with Azure Artifacts, you need to configure your .npmrc config file. This file stores feed URLs and credentials used by npm, and it allows you to customize client behavior such as setting up proxies, defining default package locations, or configuring access to private feeds. The .npmrc file is typically located in the user's home directory, but can also be created at the project level to override default settings.

Prerequisites

Product Requirements
Azure DevOps - An Azure DevOps organization.
- An Azure DevOps project.
- An Azure Artifacts feed
- Download and install Node.js and npm.

Connect to a feed

Azure Artifacts recommends using two separate .npmrc configuration files. One should be stored locally to store your credentials, while the other should be added to your project directory alongside your package.json to define your feed URL. This approach allows you to share your project-level configuration without exposing sensitive information.

To set up the credentials file, create or update the .npmrc file and include all necessary registry credentials. This enables the npm client to easily access your credentials for authentication.

The following steps guide you through setting up the project-level configuration file. Select the tab that corresponds to your development environment:

Note

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

  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 navigation pane.

  4. Add a .npmrc to your project, in the same directory as your package.json and paste the provided snippet from the Project setup section into the file.

    A screenshot displaying how to set up your npm project and connect to a feed.

  5. Run the following command to get an Azure Artifacts token added to your user-level .npmrc file. You don’t need to run this every time—npm will return a 401 Unauthorized error when it’s time to refresh the token.

    vsts-npm-auth -config .npmrc
    
  1. Sign in to your Azure DevOps collection, and then navigate to your project.

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

    A screenshot showing how to connect to a feed in Azure DevOps Server 2022.1.

  3. Select npm from the left, and then follow the steps in the Project setup section to configure your .npmrc. file and authenticate with your feed.

    A screenshot showing how to set up your npm project in Azure DevOps Server 2022.1.

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

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

    A screenshot showing how to connect to a feed in Azure DevOps Server 2020.1.

  3. Select npm from the left, and then follow the steps in the Project setup section to configure your .npmrc. file and authenticate with your feed.

    A screenshot showing how to set up your npm project in Azure DevOps Server 2020.1.

Tip

Using multiple registries in .npmrc files is supported with scopes and upstream sources.