Site Tools


blog:2021:02:05:setup-npmrc-for-azure-artifacts-in-wsl2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
blog:2021:02:05:setup-npmrc-for-azure-artifacts-in-wsl2 [2021-02-05]
dcai created
blog:2021:02:05:setup-npmrc-for-azure-artifacts-in-wsl2 [2021-02-05] (current)
dcai
Line 1: Line 1:
-===== Setup npmrc for azure artifacts in WSL2 =====+===== Setup npmrc for azure artifacts in WSL 2 =====
  
  
-I recently got a windows machine from work, I'more comfortable with mac or linux, so I installed wsl2 (ubuntu), and setup nodejs development environment in it, I followed this guide: https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows#set-up-authentication-on-your-dev-box, and created the auth token from azure personal access token:+I recently got a windows machine from work, since more comfortable with mac or linux, so I installed [[:windows:wsl|WSL 2 (ubuntu)]] to setup nodejs development environment in it, I followed the [[https://docs.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows#set-up-authentication-on-your-dev-box|guide]], and created the auth token from azure personal access token:
 <code> <code>
 echo -n [personal-access-token] | base64 echo -n [personal-access-token] | base64
- 
 </code> </code>
  
Line 28: Line 27:
 npm ERR!     /home/dcai/.npm/_logs/2021-02-04T22_20_51_870Z-debug.log</code> npm ERR!     /home/dcai/.npm/_logs/2021-02-04T22_20_51_870Z-debug.log</code>
  
-Coworker who directly work on windows told me they use [[https://www.npmjs.com/package/vsts-npm-auth|Azure DevOps (formerly VSTS) Auth helper]] for authentication on windows 10, +Same npmrc file works on macbook just not wsl2, coworker who directly work on windows told me they use [[https://www.npmjs.com/package/vsts-npm-auth|Azure DevOps (formerly VSTS) Auth helper]] for authentication on windows 10, so I installed the auth helper on windows directly, ran it by providing azure artifacts registry url, it then generated a .npmrc file under ''c:\Users\[username]\.npmrc'', I copied this file to wsl2, and it worked! The generated npmrc file looks like this: 
 + 
 +<code> 
 +//pkgs.dev.azure.com/[org]/_packaging/[feed]/npm/registry/:username=VssSessionToken 
 +; This is an unencrypted authentication token. Treat it like a password. DO NOT share this value with anyone, including Microsoft support. 
 +//pkgs.dev.azure.com/[org]/_packaging/[feed]/npm/registry/:_password=[generated-token] 
 +; The npm client won't use username and _password without an email set, but the service doesn't use the email value. The following is an arbitrarily made-up address. 
 +//pkgs.dev.azure.com/[org]/_packaging/[feed]/npm/registry/:[email protected] 
 +//[org].pkgs.visualstudio.com/_packaging/[feed]/npm/registry/:username=VssSessionToken 
 +; This is an unencrypted authentication token. Treat it like a password. DO NOT share this value with anyone, including Microsoft support. 
 +//[org].pkgs.visualstudio.com/_packaging/[feed]/npm/registry/:_password=[generated-token] 
 +; The npm client won't use username and _password without an email set, but the service doesn't use the email value. The following is an arbitrarily made-up address. 
 +//[org].pkgs.visualstudio.com/_packaging/[feed]/npm/registry/:[email protected] 
 +</code> 
 + 
 +So happy I don't have to use powershell and bulky IDE. 
 + 
 +~~DISCUSSION~~
blog/2021/02/05/setup-npmrc-for-azure-artifacts-in-wsl2.1612479873.txt.gz · Last modified: 2021-02-05 by dcai