Skip to content

Commit 46bdd1b

Browse files
authored
Merge pull request #8033 from MicrosoftDocs/artifacts/437409
npm publish & restore artifacts
2 parents e8d14e4 + a8aea2e commit 46bdd1b

File tree

2 files changed

+60
-43
lines changed

2 files changed

+60
-43
lines changed

docs/artifacts/get-started-npm.md

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,124 @@
11
---
2-
title: Publish and download npm packages
3-
description: Learn how to set up your project to manage your npm packages in Azure Artifacts.
2+
title: Publish and download npm packages with Azure Artifacts
3+
description: Learn how to configure your npm project to publish and consume packages using Azure Artifacts.
44
ms.service: azure-devops-artifacts
55
ms.topic: quickstart
66
ms.assetid: 5BFBA0C3-85ED-40C9-AC5F-F686923160D6
7-
ms.date: 05/28/2024
7+
ms.date: 06/17/2025
88
monikerRange: '>= azure-devops-2020'
99
"recommendations": "true"
1010
---
1111

12-
# Get started with npm packages in Azure Artifacts
12+
# Publish and download npm packages with Azure Artifacts
1313

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

16-
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.
16+
With Azure Artifacts, you can publish and download npm packages from both your own feeds and public registries such as npmjs.com. This quickstart guides you through creating a feed, configuring your project, and managing npm packages using Azure Artifacts.
1717

1818
## Prerequisites
1919

20-
- An Azure DevOps organization. [Create one for free](../organizations/accounts/create-organization.md).
21-
22-
- An Azure DevOps project. Create a new [project](../organizations/projects/create-project.md#create-a-project) if you don't have one already.
23-
24-
- [Download and install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
20+
| **Product** | **Requirements** |
21+
|--------------------|--------------------|
22+
| **Azure DevOps** | - An Azure DevOps [organization](../organizations/accounts/create-organization.md).<br>- An Azure DevOps [project](../organizations/projects/create-project.md).<br> - [Download and install Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). |
2523

2624
## Create a feed
2725

2826
[!INCLUDE [](includes/create-feed.md)]
2927

3028
## Connect to a feed
3129

32-
> [!NOTE]
33-
> `vsts-npm-auth` is not supported in Azure DevOps Server.
30+
Azure Artifacts recommends using two separate configuration files. The first should be kept locally in the *$HOME* directory (Linux/macOS) or *$env.HOME* (Windows) to securely store your credentials. This allows the npm client to access your credentials for authentication.
31+
32+
In this section, you'll configure the second *npmrc* file, which should be placed in the same directory as your *package.json* file.
3433

35-
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.
34+
This setup lets you share your configuration file without exposing your credentials.
3635

3736
::: moniker range="azure-devops"
3837

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

41-
1. Select **Artifacts**, and then select **Connect to feed**.
40+
1. Select **Artifacts**, select your feed from the dropdown menu, and then select **Connect to feed**.
4241

43-
1. 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.
42+
1. In the left navigation pane, select **npm**. If this is your first time using Azure Artifacts with npm, make sure you've installed the prerequisites.
4443

45-
1. Follow the instructions in the **Project setup** section to set up your config file and connect to your feed.
44+
1. Under the **Project setup** section, select **Windows** or **Other** depending on your operating system, then follow the provided instructions to configure your config file and connect to your Azure Artifacts feed.
4645

47-
:::image type="content" source="media/npm-project-setup-azure-devops.png" alt-text="A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Services.":::
46+
:::image type="content" source="media/npm-project-setup-azure-devops.png" alt-text="A screenshot displaying how to set up an npm project and connect to a feed in Azure DevOps Services.":::
4847

4948
::: moniker-end
5049

50+
5151
::: moniker range="azure-devops-2022"
5252

53+
> [!NOTE]
54+
> The `vsts-npm-auth` is not supported in Azure DevOps Server.
55+
5356
1. Sign in to your Azure DevOps collection, and then navigate to your project.
5457

55-
1. Select **Artifacts**, and then select **Connect to Feed**.
58+
1. Select **Artifacts**, select your feed from the dropdown menu, and then select **Connect to feed**.
59+
60+
1. In the left navigation pane, select **npm**. If this is your first time using Azure Artifacts with npm, make sure you've installed the prerequisites.
5661

57-
1. Select **npm** from the left, and then follow the instructions in the **Project setup** section to connect to your feed.
62+
1. Under the **Project setup** section, select **Windows** or **Other** depending on your operating system, then follow the provided instructions to configure your config file and connect to your Azure Artifacts feed.
5863

59-
:::image type="content" source="media/npm-project-setup-server-2022-1.png" alt-text="A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2022.":::
64+
:::image type="content" source="media/npm-project-setup-server-2022-1.png" alt-text="A screenshot displaying how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2022.":::
6065

6166
::: moniker-end
6267

68+
6369
::: moniker range="azure-devops-2020"
6470

71+
> [!NOTE]
72+
> The `vsts-npm-auth` is not supported in Azure DevOps Server.
73+
6574
1. Sign in to your Azure DevOps collection, and then navigate to your project.
6675

67-
1. Select **Artifacts**, and then select **Connect to feed**.
76+
1. Select **Artifacts**, select your feed from the dropdown menu, and then select **Connect to feed**.
77+
78+
1. In the left navigation pane, select **npm**. If this is your first time using Azure Artifacts with npm, make sure you've installed the prerequisites.
6879

69-
1. Select **npm** from the left, and then follow the instructions in **Project setup** to set up your config file and connect to your feed.
80+
1. Under the **Project setup** section, select **Windows** or **Other** depending on your operating system, then follow the provided instructions to configure your config file and connect to your Azure Artifacts feed.
7081

7182
:::image type="content" source="media/npm-project-setup-server-2020-1.png" alt-text="A screenshot that shows how to set up an npm project and connect to an Azure Artifacts feed in Azure DevOps Server 2020.":::
7283

7384
::: moniker-end
7485

7586
> [!IMPORTANT]
76-
> npm supports a single `registry` in your .npmrc file. Multiple registries are possible with [scopes](npm/scopes.md) and [upstream sources](npm/upstream-sources.md).
87+
> Npm supports only a single `registry` setting in your *npmrc* file. To use multiple registries, you must use [upstream sources](npm/upstream-sources.md) or [scopes](npm/scopes.md).
7788
78-
## Publish packages
89+
## Publish packages to your feed
7990

80-
Run the following command in your project directory to publish your npm packages:
91+
To successfully run the publish command, you must first authenticate with your feed. If you haven’t done this yet, follow the steps in the [Connect to a feed](#connect-to-a-feed) section then continue with the instructions below.
8192

82-
```Command
83-
npm publish
84-
```
93+
- In your project directory, run the following command to publish the npm package defined in your *package.json*:
94+
95+
```
96+
npm publish
97+
```
8598
8699
> [!IMPORTANT]
87-
> Using the `publishConfig` property to override the registry config param at publish-time is not supported.
100+
> Using the `publishConfig` property to override the registry configuration at publish time is not supported.
101+
102+
## Restore packages from your feed
103+
104+
To successfully run the restore command, you must first authenticate with your feed. If you haven’t done this yet, follow the steps in the [Connect to a feed](#connect-to-a-feed) section then continue with the instructions below.
105+
106+
1. In your project directory, run the following command to restore all npm packages:
88107
89-
## Restore packages
108+
```
109+
npm install
110+
```
90111
91-
Run the following command in your project directory to restore your npm packages:
112+
1. To restore a specific npm package, run the following command from your project directory:
92113
93-
```Command
94-
npm install
95-
```
114+
```
115+
npm install --save <PACKAGE_NAME>
116+
```
96117
97-
To restore a specific npm package, run the following command from your project directory:
118+
## Related content
98119
99-
```Command
100-
npm install --save <PACKAGE_NAME>
101-
```
120+
- [Publish npm packages with Azure Pipelines (YAML/Classic)](../pipelines/artifacts/npm.md)
102121
103-
## Related articles
122+
- [Use packages from npmjs.com](npm/upstream-sources.md)
104123
105-
- [Publish npm packages (YAML/Classic)](../pipelines/artifacts/npm.md)
106-
- [Use packages from npmjs.com](./npm/upstream-sources.md)
107-
- [Use npm scopes](npm/scopes.md)
124+
- [Use npm audit](npm/npm-audit.md)

docs/artifacts/includes/create-feed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ ms.date: 03/15/2024
4848
::: moniker-end
4949

5050
> [!NOTE]
51-
> By default, newly created feeds have their project's **Build Service** value set to **Feed and Upstream Reader (Collaborator)**.
51+
> By default, the **Build Service** for the project *(for example: projectName Build Service (orgName))* is assigned the **Feed and Upstream Reader (Collaborator)** role when a new feed is created.

0 commit comments

Comments
 (0)