-
Within your package folder (folder containing
package.json
for your package), locate where the.npmrc
for the package is located. Usually it's right alongside thepackage.json
. Creating an.npmrc
with the feed is covered in a step below.- For
openapi-alps
this is located undercommon/config/rush/.npmrc
- For
-
Ensure your project
.npmrc
has a reference to the feed containing your packages.- To get detailed instructions from devops, go to the feed and click
Connect to Feed
(top right button), then clickNPM
, and change fromWindows
tab toOther
. TheOther
tab is excellent to use for linux/mac connections.
- To get detailed instructions from devops, go to the feed and click
-
Update your project
.npmrc
with the following-
# "registry" is a url, don't make it multiline! registry=https://devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/registry/ always-auth=true
-
-
- Ensure that it has
Packaging: Read
permissions. - Ensure it is for the
devdiv
organization.- Going to user settings from the devdiv org seems to work consistently for me.
- Ensure that it has
-
Base64 the PAT. Invoke this:
# bash 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(); })" # enter the PAT and press enter
// in browser console btoa("<pat>")
- As long as you have
node
installed locally this should work. I useNode 16
as my daily driver.
- As long as you have
-
Create a
user .npmrc
.- In powershell,
cd ~/ && code .npmrc
- Populate NPMRC with:
//devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/registry/:username=devdiv //devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/registry/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN] //devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/registry/:email=npm requires email to be set but doesn't use the value //devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/:username=devdiv //devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/:_password=[BASE64_ENCODED_PERSONAL_ACCESS_TOKEN] //devdiv.pkgs.visualstudio.com/_packaging/openapi-platform/npm/:email=npm requires email to be set but doesn't use the value
- In powershell,
-
That's it! The combination of package
.npmrc
pointing out which feed to reference and your user.npmrc
providing the auth for that feed URL is what makes all this work!
Last active
September 23, 2024 10:00
-
-
Save semick-dev/2f17a36c5f39735d6a63983df9278f8b to your computer and use it in GitHub Desktop.
Connect to NPM Azure DevOps Feed
- btoa? Excellent workaround!
- Can you link the failure to me so that I can fix it for the next person? Hopefully I can ascertain what went wrong just based off the invocation error from your CLI session.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks. The node logic for Base64 PAT did not work for me. But I was able to do
btoa(PAT)
in browser console.