Uredi

Deli z drugimi prek


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 navigate to your project.

  2. Select Artifacts, and then select Create Feed.

  3. Provide a Name for your feed, choose the Visibility option that defines who can view your packages, check Include packages from common public sources if you want to include packages from sources like nuget.org or npmjs.com, and for Scope, decide whether the feed should be scoped to your project or the entire organization.

  4. Select Create when you're done.

    Screenshot that shows selections for creating a new feed in Azure DevOps Services.

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

  2. Select Artifacts, and then select Create Feed.

  3. Provide a Name for your feed, choose the Visibility option that defines who can view your packages, check Include packages from common public sources if you want to include packages from sources like nuget.org or npmjs.com, and for Scope, decide whether the feed should be scoped to your project or the entire organization.

  1. Select Create when you're done.

    Screenshot that shows selections for creating a new feed in Azure DevOps 2022.

  1. Select Create when you're done.

    Screenshot that shows selections for creating a new feed in Azure DevOps 2020.

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

  2. Select Artifacts, and then select New feed.

  3. For Name, enter a descriptive name for your feed.

    For Visibility, select an option to indicate who can view packages within the feed.

    If you want to include packages from public sources, select the Use packages from public sources through this feed option.

  4. Select Create when you're done.

    Screenshot that shows selections for creating a new feed in Azure DevOps 2019.

Note

By default, newly created feeds have their project's Build Service value 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>