Authenticate to private JFrog npm registry

Posted on
npm jfrog

This always gets me, npm publish fails to authenticate:

npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="Artifactory Realm"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rad/.npm/_logs/...Z-debug.log

The solution is:

  1. Sign-in to JFrog.
  2. Find Edit profile under the Welcome, ... menu.
  3. Put JFrog password in and unlock.
  4. Copy the encrypted password.
  5. Issue a curl request like this:
curl -u ${JFROG_USER}:${JFROG_ENCRYPTED_PASSWORD} https://${JFROG_ORG}.jfrog.io/${JFROG_ORG}/api/npm/auth
  1. Copy the output and put it in ~/.npmrc. The file should be like:
_auth="cm...M="
always-auth=true
email=email@address
registry=https://${JFROG_ORG}.jfrog.io/${JFROG_ORG}/api/npm/${JFROG_REPO}/