title | description | ms.service | ms.topic | ms.assetid | ms.date | monikerRange | recommendations |
---|---|---|---|---|---|---|---|
Publish and download npm packages |
Learn how to set up your project to manage your npm packages in Azure Artifacts. |
azure-devops-artifacts |
quickstart |
5BFBA0C3-85ED-40C9-AC5F-F686923160D6 |
05/28/2024 |
<= azure-devops |
true |
[!INCLUDE version-lt-eq-azure-devops]
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.
-
An Azure DevOps organization. Create one for free.
-
An Azure DevOps project. Create a new project if you don't have one already.
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.
::: moniker range="azure-devops"
-
Sign in to your Azure DevOps organization, and then navigate to your project.
-
Select Artifacts, and then select Connect to feed.
-
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.
-
Follow the instructions in the Project setup section to set up your config file and connect to your feed.
:::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.":::
::: moniker-end
::: moniker range="azure-devops-2022"
-
Sign in to your Azure DevOps collection, and then navigate to your project.
-
Select Artifacts, and then select Connect to Feed.
-
Select npm from the left, and then follow the instructions in the Project setup section to connect to your feed.
:::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.":::
::: moniker-end
::: moniker range="azure-devops-2020"
-
Sign in to your Azure DevOps collection, and then navigate to your project.
-
Select Artifacts, and then select Connect to feed.
-
Select npm from the left, and then follow the instructions in Project setup to set up your config file and connect to your feed.
:::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.":::
::: moniker-end
::: moniker range="azure-devops-2019"
-
Sign in to your Azure DevOps collection, and then navigate to your project.
-
Select Artifacts, and then select Connect to feed.
-
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.
:::image type="content" source="media/npm-project-setup-server-2019-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 2019.":::
::: moniker-end
Important
npm supports a single registry
in your .npmrc file. Multiple registries are possible with scopes and upstream sources.
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.
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>