|
1 | 1 | --- |
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. |
4 | 4 | ms.service: azure-devops-artifacts |
5 | 5 | ms.topic: quickstart |
6 | 6 | ms.assetid: 5BFBA0C3-85ED-40C9-AC5F-F686923160D6 |
7 | | -ms.date: 05/28/2024 |
| 7 | +ms.date: 06/17/2025 |
8 | 8 | monikerRange: '>= azure-devops-2020' |
9 | 9 | "recommendations": "true" |
10 | 10 | --- |
11 | 11 |
|
12 | | -# Get started with npm packages in Azure Artifacts |
| 12 | +# Publish and download npm packages with Azure Artifacts |
13 | 13 |
|
14 | 14 | [!INCLUDE [version-gt-eq-2020](../includes/version-gt-eq-2020.md)] |
15 | 15 |
|
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. |
17 | 17 |
|
18 | 18 | ## Prerequisites |
19 | 19 |
|
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). | |
25 | 23 |
|
26 | 24 | ## Create a feed |
27 | 25 |
|
28 | 26 | [!INCLUDE [](includes/create-feed.md)] |
29 | 27 |
|
30 | 28 | ## Connect to a feed |
31 | 29 |
|
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. |
34 | 33 |
|
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. |
36 | 35 |
|
37 | 36 | ::: moniker range="azure-devops" |
38 | 37 |
|
39 | 38 | 1. Sign in to your Azure DevOps organization, and then navigate to your project. |
40 | 39 |
|
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**. |
42 | 41 |
|
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. |
44 | 43 |
|
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. |
46 | 45 |
|
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."::: |
48 | 47 |
|
49 | 48 | ::: moniker-end |
50 | 49 |
|
| 50 | + |
51 | 51 | ::: moniker range="azure-devops-2022" |
52 | 52 |
|
| 53 | +> [!NOTE] |
| 54 | +> The `vsts-npm-auth` is not supported in Azure DevOps Server. |
| 55 | +
|
53 | 56 | 1. Sign in to your Azure DevOps collection, and then navigate to your project. |
54 | 57 |
|
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. |
56 | 61 |
|
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. |
58 | 63 |
|
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."::: |
60 | 65 |
|
61 | 66 | ::: moniker-end |
62 | 67 |
|
| 68 | + |
63 | 69 | ::: moniker range="azure-devops-2020" |
64 | 70 |
|
| 71 | +> [!NOTE] |
| 72 | +> The `vsts-npm-auth` is not supported in Azure DevOps Server. |
| 73 | +
|
65 | 74 | 1. Sign in to your Azure DevOps collection, and then navigate to your project. |
66 | 75 |
|
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. |
68 | 79 |
|
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. |
70 | 81 |
|
71 | 82 | :::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."::: |
72 | 83 |
|
73 | 84 | ::: moniker-end |
74 | 85 |
|
75 | 86 | > [!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). |
77 | 88 |
|
78 | | -## Publish packages |
| 89 | +## Publish packages to your feed |
79 | 90 |
|
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. |
81 | 92 |
|
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 | + ``` |
85 | 98 |
|
86 | 99 | > [!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: |
88 | 107 |
|
89 | | -## Restore packages |
| 108 | + ``` |
| 109 | + npm install |
| 110 | + ``` |
90 | 111 |
|
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: |
92 | 113 |
|
93 | | -```Command |
94 | | -npm install |
95 | | -``` |
| 114 | + ``` |
| 115 | + npm install --save <PACKAGE_NAME> |
| 116 | + ``` |
96 | 117 |
|
97 | | -To restore a specific npm package, run the following command from your project directory: |
| 118 | +## Related content |
98 | 119 |
|
99 | | -```Command |
100 | | -npm install --save <PACKAGE_NAME> |
101 | | -``` |
| 120 | +- [Publish npm packages with Azure Pipelines (YAML/Classic)](../pipelines/artifacts/npm.md) |
102 | 121 |
|
103 | | -## Related articles |
| 122 | +- [Use packages from npmjs.com](npm/upstream-sources.md) |
104 | 123 |
|
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) |
0 commit comments