Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to login to GitHub Package Registry

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?

like image 446
kgangadhar Avatar asked Oct 31 '19 05:10

kgangadhar


People also ask

How do I authenticate a GitHub package?

You can authenticate to GitHub Packages with npm by either editing your per-user ~/. npmrc file to include your personal access token or by logging in to npm on the command line using your username and personal access token. To authenticate by adding your personal access token to your ~/.

What is GitHub package registry?

The GitHub Package Registry is a software-package hosting service, similar to npmjs.org, rubygems.org, or hub.docker.com, that allows you to host your packages and code in one place. You can host software packages privately or publicly and use them as dependencies in your projects.

How do I add GitHub link to npm package?

Add the GitHub repository URL there: "repository": { "type": "git", "url": "https://github.com/your-user/repo-url.git" }, Make sure you specify git as type and that the URL is pointing to the actual repository, not an HTML page. So the URL has to end with .


3 Answers

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
like image 188
J.S. Peterson Avatar answered Nov 10 '22 21:11

J.S. Peterson


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

like image 44
Minion3665 Avatar answered Nov 10 '22 22:11

Minion3665


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

like image 21
niconiahi Avatar answered Nov 10 '22 23:11

niconiahi