Skip to content

Commit 9509e77

Browse files
author
Rami Bououni
committed
save npm auth
1 parent 4fdb961 commit 9509e77

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

docs/artifacts/npm/npmrc.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
11
---
2-
title: Connect your npm project to Azure Artifacts
3-
description: Learn how to set up your npm project and connect to Azure Artifacts
2+
title: Connect to an Azure Artifacts feed - npm
3+
description: Learn how to set up your npm project and connect to an Azure Artifacts feed.
44
ms.assetid: A5364E3A-3918-4318-AAE0-430EA91AD5F1
55
ms.service: azure-devops-artifacts
66
ms.custom: engagement-fy23
77
ms.topic: conceptual
8-
ms.date: 03/13/2025
8+
ms.date: 07/08/2025
99
monikerRange: '>= azure-devops-2020'
1010
"recommendations": "true"
1111
---
1212

13-
# Connect your npm project to Azure Artifacts
13+
# Connect to an Azure Artifacts feed - npm
1414

1515
[!INCLUDE [version-gt-eq-2020](../../includes/version-gt-eq-2020.md)]
1616

17-
Azure Artifacts enables developers to manage their packages from various sources, including both public registries like npmjs.com and private feeds. To authenticate with Azure Artifacts, you'll need to configure your npm config file. This file contains feed URLs and credentials used by npm, offering options to customize your npm client behavior, such as setting up proxies, defining default package locations, or configuring private package 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.
17+
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.
1818

1919
## Prerequisites
2020

21-
- An Azure DevOps organization. [Create one for free](../../organizations/accounts/create-organization.md).
21+
| **Product** | **Requirements** |
22+
|--------------------|--------------------|
23+
| **Azure DevOps** | - An Azure DevOps [organization](../../organizations/accounts/create-organization.md).<br>- An Azure DevOps [project](../../organizations/projects/create-project.md).<br>- An Azure Artifacts [feed](../get-started-npm.md#create-a-feed)<br> - [Download and install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).|
2224

23-
- An Azure DevOps project. Create a new [project](../../organizations/projects/create-project.md#create-a-project) if you don't have one already.
25+
## Connect to a feed
2426

25-
- An Azure Artifacts feed. [Create one for free](../get-started-npm.md#create-a-feed).
27+
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.
2628

27-
- [Download and install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
29+
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.
2830

29-
## Connect to Feed
30-
31-
Azure Artifacts recommends using two separate configuration files. The first is dedicated to authenticating with Azure Artifacts, while the second should be kept locally to store your credentials. This approach allows you to share your configuration file while keeping your credentials secure.
32-
33-
To set up the second file, place it in your home directory on your development machine and include all your registry credentials. This enables the npm client to easily access your credentials for authentication.
34-
35-
The following steps guide you through setting up the first configuration file. Select the tab that corresponds to your development environment:
31+
The following steps guide you through setting up the project-level configuration file. Select the tab that corresponds to your development environment:
3632

3733
::: moniker range="< azure-devops"
3834

@@ -47,17 +43,21 @@ The following steps guide you through setting up the first configuration file. S
4743

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

50-
1. Select **Artifacts**, and then select **Connect to Feed**.
51-
52-
:::image type="content" source="../media/npm-connect-to-feed-azure-devops.png" alt-text="A screenshot showing how to connect to a feed in Azure DevOps Services.":::
46+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
5347

54-
1. Select **npm** from the left sidebar. If this is the first time using Azure Artifacts with npm, make sure you've installed the prerequisites.
48+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
5549

56-
1. Follow the instructions in the **Project setup** section to connect to your feed.
50+
1. Add a *.npmrc* to your project, in the same directory as your *package.json* and paste the provided snippet from the **Project setup** into the file.
5751

58-
:::image type="content" source="../media/npm-project-setup-azure-devops.png" alt-text="A screenshot showing how to set up your npm project.":::
52+
:::image type="content" source="../media/npm-project-setup-azure-devops.png" alt-text="A screenshot displaying how to set up your npm project and connect to a feed.":::
5953

60-
### [Linux/macOS](#tab/Linuxmac/)
54+
1. 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.
55+
56+
```
57+
vsts-npm-auth -config .npmrc
58+
```
59+
60+
### [Other](#tab/other/)
6161
6262
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the following snippet into it.
6363

0 commit comments

Comments
 (0)