You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/artifacts/npm/npm-audit.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ This synchronization ensures that other projects sharing the same feed will also
34
34
npm audit
35
35
```
36
36
37
-
1. If you want to attempt to upgrade to non-vulnerable package versions, make sure you're [connected to your feed](./npmrc.md#connect-to-feed) first, then run the following command in your project directory:
37
+
1. If you want to attempt to upgrade to non-vulnerable package versions, make sure you're [connected to your feed](npmrc.md#connect-to-a-feed) first, then run the following command in your project directory:
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.
18
18
19
19
## Prerequisites
20
20
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).|
22
24
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
24
26
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.
26
28
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.
28
30
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:
36
32
37
33
::: moniker range="< azure-devops"
38
34
@@ -47,19 +43,31 @@ The following steps guide you through setting up the first configuration file. S
47
43
48
44
1. Sign in to your Azure DevOps organization, and then navigate to your project.
49
45
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.
47
+
48
+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
49
+
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** section into the file.
51
+
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.":::
53
53
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.
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/)
61
+
62
+
1. Sign in to your Azure DevOps organization, and then navigate to your project.
55
63
56
-
1.Follow the instructions in the **Project setup** section to connect to your feed.
64
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
57
65
58
-
:::image type="content" source="../media/npm-project-setup-azure-devops.png" alt-text="A screenshot showing how to set up your npm project.":::
66
+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
59
67
60
-
### [Linux/macOS](#tab/Linuxmac/)
68
+
1. Add a *.npmrc* file to your project's directory. This should be the same directory where your *package.json* file is located.
61
69
62
-
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.
70
+
1. Paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
@@ -99,19 +107,19 @@ The following steps guide you through setting up the first configuration file. S
99
107
100
108
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
101
109
102
-
1. Run the following command in a command prompt window, and then paste your personal access token when prompted. Once done, copy the generated Base 64 encoded value.
110
+
1. Run the following command in a command prompt window. When prompted, paste your personal access token (PAT) and press **Enter**. The script will return a Base64-encoded version of your PAT, copy that value to use in the next step.
1. If you're on Linux/Mac, you can alternatively use the following command to convert your personal access token to Base 64. Copy the resulting Base64 encoded value.
116
+
1. If you're using Linux or macOS, you can run the following command in your terminal to convert your personal access token (PAT) to a Base64-encoded string. Copy the resulting value to use in the next step.
109
117
110
118
```
111
119
echo -n "YOUR_PERSONAL_ACCESS-TOKEN" | base64
112
120
```
113
121
114
-
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user *.npmrc* file with the encoded personal access token obtained from the previous step.
122
+
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
115
123
116
124
* * *
117
125
@@ -123,23 +131,30 @@ The following steps guide you through setting up the first configuration file. S
123
131
124
132
1. Sign in to your Azure DevOps collection, and then navigate to your project.
125
133
126
-
1. Select **Artifacts**, and then select **Connect to Feed**.
134
+
1. Select **Artifacts**, select your feed from the dropdown menu, and then select **Connect to Feed**.
127
135
128
136
:::image type="content" source="../media/server-2022-1-connect-to-feed.png" alt-text="A screenshot showing how to connect to a feed in Azure DevOps Server 2022.1.":::
129
137
130
-
1. Select **npm** from the left sidebar, and then follow the instructions in the **Project setup** section to set up your config file.
138
+
1. Select **npm** from the left, and then follow the steps in the **Project setup** section to configure your .npmrc. file and authenticate with your feed.
131
139
132
140
:::image type="content" source="../media/npm-project-setup-server-2022-1.png" alt-text="A screenshot showing how to set up your npm project in Azure DevOps Server 2022.1.":::
133
141
134
-
### [Linux/macOS](#tab/Linuxmac/)
142
+
### [Other](#tab/other/)
135
143
136
-
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.
144
+
1. Sign in to your Azure DevOps collection, and then navigate to your project.
145
+
146
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
147
+
148
+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
149
+
150
+
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
1. Copy the following snippet and paste it into your user-level *.npmrc* file:
@@ -172,13 +187,13 @@ The following steps guide you through setting up the first configuration file. S
172
187
173
188
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
174
189
175
-
1. Run the following command in a command prompt window, and then paste your personal access token when prompted. Once done, copy the generated Base 64 encoded value.
190
+
1. Run the following command in a command prompt window. When prompted, paste your personal access token and press **Enter**. The script will return a Base64-encoded version of your PAT, copy that value to use in the next step.
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user *.npmrc* file with the encoded personal access token obtained from the previous step.
196
+
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
182
197
183
198
* * *
184
199
@@ -194,13 +209,19 @@ The following steps guide you through setting up the first configuration file. S
194
209
195
210
:::image type="content" source="../media/server-2020-1-connect-to-feed.png" alt-text="A screenshot showing how to connect to a feed in Azure DevOps Server 2020.1.":::
196
211
197
-
1. Select **npm** from the left, and then follow the instructions in **Project setup** to set up your config file.
212
+
1. Select **npm** from the left, and then follow the steps in the **Project setup** section to configure your .npmrc. file and authenticate with your feed.
198
213
199
214
:::image type="content" source="../media/npm-project-setup-server-2020-1.png" alt-text="A screenshot showing how to set up your npm project in Azure DevOps Server 2020.1.":::
200
215
201
-
### [Linux/macOS](#tab/Linuxmac/)
216
+
### [Other](#tab/other/)
217
+
218
+
1. Sign in to your Azure DevOps collection, and then navigate to your project.
202
219
203
-
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:
220
+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
221
+
222
+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
223
+
224
+
1. Add a *.npmrc* file in your project's directory, in the same directory as your *package.json* file, and paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
@@ -209,7 +230,7 @@ The following steps guide you through setting up the first configuration file. S
209
230
```
210
231
211
232
> [!NOTE]
212
-
> For Debian, Ubuntu, and other community or entreprise distributions such as Fedora or Redhat make sure you've installed the prerequisites from the [NodeSource distributions repository](https://github.com/nodesource/distributions).
233
+
> For Debian, Ubuntu, and other community or enterprise distributions such as Fedora or Redhat make sure you've installed the prerequisites from the [NodeSource distributions repository](https://github.com/nodesource/distributions).
213
234
214
235
### Setup credentials
215
236
@@ -243,73 +264,25 @@ The following steps guide you through setting up the first configuration file. S
243
264
244
265
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
245
266
246
-
1. Run the following command in a command prompt window, and then paste your personal access token when prompted. Once done, copy the generated Base 64 encoded value.
267
+
1. Run the following command in a command prompt window. When prompted, paste your personal access token and press **Enter**. The script will return a Base64-encoded version of your PAT, copy that value to use in the next step.
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user *.npmrc* file with the encoded personal access token obtained from the previous step.
273
+
1. Replace the placeholders *[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN]* in your user-level *.npmrc* file with the Base64-encoded personal access token you generated in the previous step.
253
274
254
275
* * *
255
276
256
277
::: moniker-end
257
278
258
279
> [!TIP]
259
-
> Using multiple registries in .npmrc files is supported with [scopes](..//npm/scopes.md) and [upstream sources](../concepts/upstream-sources.md).
260
-
261
-
::: moniker range="azure-devops"
262
-
263
-
## Troubleshoot
264
-
265
-
#### vsts-npm-auth is not recognized
266
-
267
-
This error indicates that the npm modules folder hasn't been added to your path. Rerun the Node.js setup and make sure to select the `Add to PATH` option. Alternatively, you can add the npm modules folder to your path by modifying the PATH variable to `%APPDATA%\npm` in Command Prompt or `$env:APPDATA\npm` in PowerShell.
268
-
269
-
:::image type="content" source="./media/node-setup.png" alt-text="A Screenshot showing how to set up node.js.":::
270
-
271
-
#### Unable to authenticate
272
-
273
-
- Error: *code E401 npm ERR! Unable to authenticate*: -> Run the `vsts-npm-auth` command with **-F** flag to reauthenticate:
274
-
275
-
```
276
-
vsts-npm-auth -config .npmrc -F
277
-
```
278
-
279
-
#### Reset vsts-npm-auth
280
-
281
-
Follow these steps to reset your vsts-npm-auth credentials:
If you encounter a 403 error, it may indicate a name conflict. In Azure Artifacts, packages are immutable, meaning that once you publish a package to your feed, its version number is permanently reserved. Even if you delete it, you can't publish a new package with the same version number. To address this issue, update the package version in your *package.json* file, and then try again.
306
-
307
-
::: moniker-end
280
+
> Using multiple registries in *.npmrc* files is supported with [scopes](..//npm/scopes.md) and [upstream sources](../concepts/upstream-sources.md).
Copy file name to clipboardExpand all lines: docs/artifacts/npm/publish.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ If this is your first time using Azure Artifacts with npm on your machine, follo
46
46
47
47
## Publish packages
48
48
49
-
1. If you haven't authenticated with your feed yet, follow the steps in the [Project setup](npmrc.md#connect-to-feed) to connect to your feed and then proceed with the next step once you're done.
49
+
1. If you haven't authenticated with your feed yet, follow the steps in the [Project setup](npmrc.md#connect-to-a-feed) to connect to your feed and then proceed with the next step once you're done.
50
50
51
51
1. Run the following command in your project directory to publish the npm packages listed in your *package.json*:
Copy file name to clipboardExpand all lines: docs/artifacts/npm/restore-npm-packages.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ If this is your first time using Azure Artifacts with npm on your machine, follo
43
43
44
44
## Restore packages
45
45
46
-
1. If you haven't authenticated with your feed yet, follow the steps in the [Project setup](npmrc.md#connect-to-feed) to connect to your feed and then proceed with the next step once you're done.
46
+
1. If you haven't authenticated with your feed yet, follow the steps in the [Project setup](npmrc.md#connect-to-a-feed) to connect to your feed and then proceed with the next step once you're done.
47
47
48
48
1. Run the following command in your project directory to restore all your npm packages:
Copy file name to clipboardExpand all lines: docs/artifacts/npm/upstream-sources.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ If you checked the upstream sources checkbox during the creation of your feed, n
54
54
55
55
## Install packages from npmjs
56
56
57
-
Before you save packages from npmjs, make sure your project is set up to connect to your feed. If you haven't done this yet, follow the provided instructions to [set up your npm project](npmrc.md#connect-to-feed) and connect to your feed. In this example, we'll install the *Axios* library for making HTTP requests:
57
+
Before you save packages from npmjs, make sure your project is set up to connect to your feed. If you haven't done this yet, follow the provided instructions to [set up your npm project](npmrc.md#connect-to-a-feed) and connect to your feed. In this example, we'll install the *Axios* library for making HTTP requests:
58
58
59
59
1. Navigate to npmjs at `https://www.npmjs.com//`.
0 commit comments