Using User Token’s with NPM


The npm cli login has a limitation of lower case characters and numbers for the username whereas Nexus Repository Manager User Token’s include any characters that are available with Base64 encoding as described in



In order to use npm with User Token’s a simple solution is to edit your .npmrc file and use Basic Authentication, adding your base64 encoded User Token. This is described in more detail here; below is a short example:


An example .npmrc:

registry = http://localhost:8081/nexus/content/groups/npm-group/


where _auth value is the base64 encoded representation of your User Token “<userCode>:<passCode>”.


Option 1:

To generate the base64 encoded string you can do the following:

echo -n '<userCode>:<passCode>' | openssl base64


Option 2:

From Nexus Repository Manager version 3.7 onwards, the User Token details view now displays the generated base64 encoded string that you can copy and paste into your .npmrc directly. As an example, see the screenshot below:



Have more questions? Submit a request


Article is closed for comments.
Powered by Zendesk