npm ERR! Unable to authenticate, need: Basic realm=”Artifactory Realm”

Artifactory moved to support APIKEY only. If your old _auth was base64 encoding of username:password or username:encrypted_password then both are unacceptable now. You must use APIKEY in place of these.

So, the supported _auth now becomes:

_auth: APIKEY

But ironically, even this didn’t work in some cases.

Following seemed to be more reliable:

  1. You need to get base64 string of your username:APIKEY. You can get base64 by running following command in PowerShell

[System.Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("username:APIKEY"))

  1. Whatever is the output, use that in _auth variable of your .npmrc file (located in %userprofile%\.npmrc)

So, the final file looks like following:

registry=<URL>
_auth = <Base64 of username:APIKEY>
email = [email protected]
always-auth = true

Leave a Comment

tech