19

I am trying to release npm package through GitHub Package Registry, I am following the documentation, When I try to login using the below command after entering the username and password(even though both are correct), I am getting below error always.

// Step 2: Authenticate
$ npm login --registry=https://npm.pkg.github.com/

Error log:

npm login --registry=https://npm.pkg.github.com/
Username: ***********
Password:
Email: (this IS public) *****************
npm ERR! code E401
npm ERR! Registry returned 401 for PUT on https://npm.pkg.github.com/-/user/org.couchdb.user:kgangadhar: Error authenticating user: Bad credentials

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\karth\AppData\Roaming\npm-cache\_logs\2019-10-31T05_35_05_829Z-debug.log

Does anyone know how to resolve it?

kgangadhar
  • 4,886
  • 5
  • 36
  • 54

3 Answers3

26

Do you have 2-factor authentication enabled on your GitHub account? If so, try creating a personal access token and using that instead of a password. Here are instructions to create a token.

Update: Github now requires personal access tokens for all accounts, regardless of if you have 2fa enabled

Minion3665
  • 879
  • 11
  • 25
24

I ran into this same issue because I was attempting to use my Github password to login, when in fact you need to use a Github Personal Access Token as the password.

Username: YOUR_GITHUB_USERNAME  
Password: YOUR_GITHUB_PERSONAL_ACCESS_TOKEN  
Email: YOUR_EMAIL
J.S. Peterson
  • 2,839
  • 1
  • 14
  • 17
10

In this article refences the same command you are executing and the previous answer is correct. Just leaving here this to reinforce it:

Link to Github configuration page

There just Ctrl + F in search for npm login --registry=https://npm.pkg.github.com

niconiahi
  • 545
  • 4
  • 5