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 https://en.wikipedia.org/wiki/Base64#Base64_table.
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>”.
To generate the base64 encoded string you can do the following:
echo -n '<userCode>:<passCode>' | openssl base64
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: