This is part 2 of the Email usernames in npm series. If you haven't read the first part, here it is: Allowing "at" characters in npm usernames
Back in 2018, I was having problems signing in to Proget's npm registry with an email address as my username. The npm command line tools would not accept an
@ sign as part of the username. The solution was to edit the
.npmrc file and manually add the username and password.
Fast-forward to 2021, and I have the same problem using Azure Artifacts in Azure Devops. There is a command-line tool called
vsts-npm-auth that lets you sign in to an Azure Devops npm registry correctly, but unfortunately, that tool only works on Windows (which is a weird design decision in 2021). Also, with Azure Artifacts, you need to use a personal access token (PAT) instead of your normal password. So you need to go to the User Settings menu, select Personal Access Tokens, create a new token, and set the read and write rights on the Packaging scope. Copy the token, base64-encode it, and add it to your
# Settings for @PROJECT @PROJECT:registry=https://ORGANIZATION.pkgs.visualstudio.com/_packaging/PROJECT/npm/registry/ //ORGANIZATION.pkgs.visualstudio.com/_packaging/PROJECT/npm/registry/:username=USER@DOMAIN //ORGANIZATION.pkgs.visualstudio.com/_packaging/PROJECT/npm/registry/:_password=BASE64(ACCESS_TOKEN) //ORGANIZATION.pkgs.visualstudio.com/_packaging/PROJECT/npm/registry/:email=EMAIL_ADDRESS //ORGANIZATION.pkgs.visualstudio.com/_packaging/PROJECT/npm/registry/:always-auth=true
Articles in this series: