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?
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 ~/.
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.
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 .
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With