title: 401 Unauthorized while using GitHub NPM registry
body: <p>I am trying to use <code>npm.pkg.github.com</code> to host a NPM package.</p>
  <p>I followed this guide <a href="https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry" rel="nofollow noreferrer">https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry</a></p>
  <p>When I try to run <code>npm login ...</code> (see bellow) I got the error <em><strong>&quot;401 Unauthorized&quot;</strong></em>.</p>
  <p>My password is correct, I checked more than four times.</p>
  <pre><code>npm login --scope=@mycompany --registry=https://npm.pkg.github.com
  Username: myuser
  Password: 
  Email: (this IS public) myemail@gmail.com
  npm ERR! code E401
  npm ERR! 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/ubuntu/.npm/_logs/2021-09-23T13_35_53_341Z-debug.log
  </code></pre>
  <p>Here the logs</p>
  <pre><code>0 info it worked if it ends with ok
  1 verbose cli [
  1 verbose cli   '/home/ubuntu/.nvm/versions/node/v14.17.6/bin/node',
  1 verbose cli   '/home/ubuntu/.nvm/versions/node/v14.17.6/bin/npm',
  1 verbose cli   'login',
  1 verbose cli   '--scope=@mycompany',
  1 verbose cli   '--registry=https://npm.pkg.github.com'
  1 verbose cli ]
  2 info using npm@6.14.15
  3 info using node@v14.17.6
  4 verbose npm-session 31a7580c954cdd70
  5 verbose web login before first POST
  6 http fetch POST 404 https://npm.pkg.github.com/-/v1/login 308ms
  7 verbose web login not supported, trying couch
  8 verbose login before first PUT {
  8 verbose login   _id: 'org.couchdb.user:myuser',
  8 verbose login   name: 'myuser',
  8 verbose login   password: 'XXXXX',
  8 verbose login   type: 'user',
  8 verbose login   roles: [],
  8 verbose login   date: '2021-09-23T13:35:52.873Z'
  8 verbose login }
  9 http fetch PUT 401 https://npm.pkg.github.com/-/user/org.couchdb.user:myuser 288ms
  10 verbose adduser before first PUT {
  10 verbose adduser   _id: 'org.couchdb.user:myuser',
  10 verbose adduser   name: 'myuser',
  10 verbose adduser   password: 'XXXXX',
  10 verbose adduser   email: 'myemail@gmail.com',
  10 verbose adduser   type: 'user',
  10 verbose adduser   roles: [],
  10 verbose adduser   date: '2021-09-23T13:35:53.162Z'
  10 verbose adduser }
  11 http fetch PUT 401 https://npm.pkg.github.com/-/user/org.couchdb.user:myuser 170ms
  12 verbose stack Error: 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication
  12 verbose stack     at /home/ubuntu/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:117:15
  12 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:95:5)
  13 verbose statusCode 401
  14 verbose cwd /home/ubuntu/workspace/mycompany/uikit
  15 verbose Linux 5.10.16.3-microsoft-standard-WSL2
  16 verbose argv &quot;/home/ubuntu/.nvm/versions/node/v14.17.6/bin/node&quot; &quot;/home/ubuntu/.nvm/versions/node/v14.17.6/bin/npm&quot; &quot;login&quot; &quot;--scope=@mycompany&quot; &quot;--registry=https://npm.pkg.github.com&quot;
  17 verbose node v14.17.6
  18 verbose npm  v6.14.15
  19 error code E401
  20 error 401 Unauthorized - PUT https://npm.pkg.github.com/-/user/org.couchdb.user:myuser - Error authenticating user: Requires authentication
  21 verbose exit [ 1, true ]
  </code></pre>
  <p>When I ran <code>npm whoam</code></p>
  <pre><code>npm ERR! code ENEEDAUTH
  npm ERR! need auth This command requires you to be logged in.
  npm ERR! need auth You need to authorize this machine using `npm adduser`
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/ubuntu/.npm/_logs/2021-09-23T17_13_01_791Z-debug.log
  </code></pre>
  <p><code>npm --version</code></p>
  <blockquote>
  <p>6.14.15</p>
  </blockquote>
  <p>Also, I have on my <code>.npmrc</code> this line</p>
  <pre><code>//npm.pkg.github.com/:_authToken=SECRET_TOKEN
  </code></pre>
  <p>The most strange is: <code>/user/org.couchdb.user</code>. I am not part of couchdb org.</p>
  <p>What I am doing wrong?</p>