.npmrc file with registry= not overwritten and causing 401 error
See original GitHub issueExample: 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:
- Created 4 years ago
- Reactions:5
- Comments:17 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.Assign OWNER_TOKEN from ${{secrets.GITHUB_TOKEN}} in actions, and assign it from a PAT locally.
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 usingOWNER:registry=https://npm.pkg.github.com/
. Perhaps the documentation should be updated?