title: Authentication error on publishing to private NPM repository on Nexus
body: <p>I am having authentication problem when publishing to my private npm registry hosted on my private Nexus.</p>
  <p>My Nexus setup is I have <strong>npm-proxy</strong>, <strong>npm-registry</strong> (hosted npm with <code>allowRepublish=false</code>), <strong>npm-snapshots</strong> (hosted npm with <code>allowRepublish=true</code>) and <strong>npm-public</strong> (group with all other three repositories).</p>
  <p>Since I am developing a library, I am using my snapshot repository, so I can redeploy same version constantly (something like snapshot in maven world).</p>
  <p>In my library project I have set this option in <strong>package.json</strong></p>
  <pre><code>&quot;publishConfig&quot;: {
      &quot;registry&quot;: &quot;https://my.nexus.com/repository/npm-snapshots/&quot;
  }
  </code></pre>
  <p>Next, I created <strong>.npmrc</strong> file with following content:</p>
  <pre><code>registry=https://my.nexus.com/repository/npm-public/
  _auth=RVhBTVBMRQ==
  </code></pre>
  <p>And with this setup I can publish project with no problem. However, what bothers me, is that I have my password (which is just base64 encoded) stored in file, that should be commited, but I can't commit it, due to credentials in it.</p>
  <p>I have tried to instead login to npm registry and removed the auth line from .npmrc
  <code>npm adduser --registry=https://my.nexus.com/repository/npm-snapshots --always-auth</code></p>
  <p>I got response <code>Logged in as myusername on https://my.nexus.com/repository/npm-snapshots.</code></p>
  <p>However, when I try to run <code>npm publish</code> I get:</p>
  <pre><code>npm ERR! code E401
  npm ERR! Unable to authenticate, need: BASIC realm=&quot;Sonatype Nexus Repository Manager&quot;
  npm verb exit [ 1, true ]
  npm timing npm Completed in 6867ms
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\XXXX\AppData\Roaming\npm-cache\_logs\2019-07-30T19_31_01_598Z-debug.log
  </code></pre>
  <p>Now in my other project (which is using this library), I simply created .npmrc file with content <code>registry=https://nexus.mjamsek.com/repository/npm-public/</code> and run command <code>npm adduser --registry=https://my.nexus.com/repository/npm-public --always-auth</code> and I was able to download the published package.</p>
  <p>However, the publish still won't work and I don't know why.</p>
  <p>EDIT 31.7.2019: On my list of active realms I also have <strong>npm Bearer Token Realm</strong></p>