question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.npmrc file with registry= not overwritten and causing 401 error

See original GitHub issue

Example: https://github.com/rynz/node-test-protocol/pull/6

In this example exists an empty .npmrc and when it is populated with registry= an error occurs:

npm ERR! 401 Unauthorized - GET https://npm.pkg.github.com/rynz/prettier - could not retrieve user by token

For whatever reason, the registry= is not being removed correctly like https://github.com/actions/setup-node/blob/master/src/authutil.ts#L41 is supposed to do.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
joebowbeercommented, Mar 1, 2020

I’m having a hard time believing that the registry line is not removed.

A config that will work both locally and in actions is to avoid specifying registry-url or scope in the with line, so that .npmrc is not modified, and use an explicit config in .npmrc.

@owner:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=$OWNER_TOKEN

Assign OWNER_TOKEN from ${{secrets.GITHUB_TOKEN}} in actions, and assign it from a PAT locally.

4reactions
rynzcommented, Feb 27, 2020

Reopening because I’ve found the documentation that causes the bug in the first place: https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-npm-for-use-with-github-packages#publishing-a-package-using-a-local-npmrc-file

It states to use, registry=https://npm.pkg.github.com/OWNER where as we should be using OWNER:registry=https://npm.pkg.github.com/. Perhaps the documentation should be updated?

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - NPM ERR Code E401: Unable to authenticate, need
This is what worked for me. First, delete the .npmrc file in your Users folder. This folder: C:\Users\[your user name].
Read more >
We've set up a Packages repo and published an NPM ...
Thanks for submitting the feedback. The 401 error may be caused by the authentication token configure in the .npmrc file doesn't have permission...
Read more >
npm error code e401 | The AI Search Engine You Control
"How to fix the issue First, you can verify your token by running npm whoami . If it's invalid or you got the...
Read more >
Troubleshooting - SAP Capire
Type npm config list to check the configuration, which is stored in a file .npmrc in the user's home directory. There, no @sap:registry...
Read more >
14 Use the Project's NPM Registry - Oracle Help Center
Paste the content you just copied into your local .npmrc file and save it. ... If it does, the Package already exists and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found