So to recap, your problem is that your private registry uses email addresses for user names, which is not currently supported by the npm command line tools. You need a way to provide your user name without running npm adduser
or npm login
. I don’t know which registry you are using, but I had the same problem with Inedo’s Proget.
EDIT: I have the same problem in March 2021, with Azure Artifacts in Azure DevOps, because the npm command-line tools still don’t allow @
in usernames, and also the vsts-npm-auth
command-line tool does not work on Linux or Mac. I have also had the same problem with Artifactory.
If you’re using a private registry and you are using scopes to separate the different registries, you can create an .npmrc
file that looks like this:
#Settings for @SCOPENAME
@SCOPENAME:registry=https://DOMAIN/FEED/
//DOMAIN/FEED/:username=USER@DOMAIN
//DOMAIN/FEED/:_password=BASE64(PASSWORD)
//DOMAIN/FEED/:email=EMAIL_ADDRESS
//DOMAIN/FEED/:always-auth=true
#Settings for @OTHERSCOPENAME
@OTHERSCOPENAME:registry=...
This next bit might be important, but it depends on your registry’s preferred feed urls: I couldn’t get this to work properly without the trailing /
so take care to try both with and without it.
An easy way to get the base64 encoding of your password is to run:
echo -n 'PASSWORD' | base64
EDIT: For some registries, like Azure Artifacts, you need to use a personal access token instead of your normal password. Look up the instructions for your registry about how to create a token.
EDIT: It’s also possible to have the .npmrc
file without scopes, if you are only using one registry:
# Global settings
registry=https://DOMAIN/FEED/
//DOMAIN/FEED/:username=USER@DOMAIN
//DOMAIN/FEED/:_password=BASE64(PASSWORD)
//DOMAIN/FEED/:email=EMAIL_ADDRESS
//DOMAIN/FEED/:always-auth=true