Edit

Connect to an Azure Artifacts feed - npm

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

Azure Artifacts uses the .npmrc configuration file to authenticate npm clients with feeds. The recommended setup keeps feed configuration and credentials in two separate .npmrc files: a project-level file (checked in alongside your package.json) that stores the feed URL, and a user-level file (never committed) that stores your credentials.

Prerequisites

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

Connect to a feed

Select the tab that matches your operating system and follow the steps to configure your .npmrc files:

Note

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

  1. Sign in to your Azure DevOps organization, and then go 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. If you didn't install vsts-npm-auth, run the following command:

    npm install -g vsts-npm-auth --registry https://registry.npmjs.com --always-auth false
    
  5. Add a .npmrc file to your project in the same directory as your package.json, and then paste the snippet from the Project setup section into the file.

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

  6. Run the following command to add a token to your user-level .npmrc file. npm returns a 401 Unauthorized error when the token expires—run this command again to refresh it.

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

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

    Screenshot showing how to connect to an Azure Artifacts feed in Azure DevOps Server 2022.1.

  3. Select npm, 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.

Tip

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