Skip to content

Commit 54fa289

Browse files
author
Rami Bououni
committed
auth OS
1 parent 9509e77 commit 54fa289

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

docs/artifacts/npm/npmrc.md

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The following steps guide you through setting up the project-level configuration
4747

4848
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
4949

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.
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.
5151

5252
:::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.":::
5353

@@ -59,7 +59,15 @@ The following steps guide you through setting up the project-level configuration
5959
6060
### [Other](#tab/other/)
6161
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.
62+
1. Sign in to your Azure DevOps organization, and then navigate to your project.
63+
64+
1. Select **Artifacts**, and then select your feed from the dropdown menu.
65+
66+
1. Select **Connect to Feed** and then select **npm** from the left navigation pane.
67+
68+
1. Add a *.npmrc* file to your project's directory. This should be the same directory where your *package.json* file is located.
69+
70+
1. Paste the snippet provided in the **Project setup** section into your *.npmrc* file. Your file should look similar to the following:
6371
6472
```
6573
registry=https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/npm/registry/
@@ -99,19 +107,19 @@ The following steps guide you through setting up the project-level configuration
99107
100108
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
101109
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.
103111
104112
```
105113
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
106114
```
107115
108-
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.
109117
110118
```
111119
echo -n "YOUR_PERSONAL_ACCESS-TOKEN" | base64
112120
```
113121
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.
115123
116124
* * *
117125
@@ -123,23 +131,30 @@ The following steps guide you through setting up the project-level configuration
123131
124132
1. Sign in to your Azure DevOps collection, and then navigate to your project.
125133
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**.
127135
128136
:::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.":::
129137
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.
131139
132140
:::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.":::
133141
134-
### [Linux/macOS](#tab/Linuxmac/)
142+
### [Other](#tab/other/)
143+
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.
135149
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.
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:
137151
138152
```
139153
registry=http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/npm/registry/
140154
141155
always-auth=true
142156
```
157+
143158
### Setup credentials
144159
145160
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 project-level configuration
172187
173188
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
174189
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.
176191
177192
```
178193
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
179194
```
180195
181-
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.
182197
183198
* * *
184199
@@ -194,13 +209,19 @@ The following steps guide you through setting up the project-level configuration
194209
195210
:::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.":::
196211
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.
198213
199214
:::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.":::
200215
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.
219+
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.
202223
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:
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:
204225
205226
```
206227
registry=http://<SERVER_NAME>/<COLLECTION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/npm/registry/
@@ -243,20 +264,20 @@ The following steps guide you through setting up the project-level configuration
243264
244265
1. Generate a [personal access token](../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with **packaging read and write** scopes.
245266
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.
247268
248269
```
249270
node -e "require('readline') .createInterface({input:process.stdin,output:process.stdout,historySize:0}) .question('PAT> ',p => { b64=Buffer.from(p.trim()).toString('base64');console.log(b64);process.exit(); })"
250271
```
251272
252-
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.
253274
254275
* * *
255276
256277
::: moniker-end
257278
258279
> [!TIP]
259-
> Using multiple registries in .npmrc files is supported with [scopes](..//npm/scopes.md) and [upstream sources](../concepts/upstream-sources.md).
280+
> Using multiple registries in *.npmrc* files is supported with [scopes](..//npm/scopes.md) and [upstream sources](../concepts/upstream-sources.md).
260281
261282
::: moniker range="azure-devops"
262283

0 commit comments

Comments
 (0)