[Bug] YN0041: Invalid authentication after logging in with `yarn npm login`
See original GitHub issue- I’d be willing to implement a fix
Describe the bug
I attempted to publish my package via yarn npm login
and yarn npm publish
, but yarn failed with an unexpected error
To Reproduce
Using yarn
from sources in this repo: https://github.com/justjake/quickjs-emscripten
- Clone https://github.com/justjake/quickjs-emscripten
- Try to
yarn npm login
- Try to
yarn npm publish
Screenshots
If applicable, add screenshots to help explain your problem.
Environment if relevant (please complete the following information):
- OS: macOS 10.14.6 (18G103)
- Node version: v10.21.0
- Yarn version: 2.1.1-git.20200720.906e9472
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:23 (9 by maintainers)
Top Results From Across the Web
How to associate registry with scope in Yarn 2 without ...
However, when I do a yarn install , I get an Invalid authentication (as an anonymous user) error for packages in that scope....
Read more >yarn login
yarn login. Running this command will prompt you for your username and email for the npm registry. It will not ask for your...
Read more >[RTFACT-24151] Scoped npm packages have incorrect paths ...
When publishing a scoped npm package to JFrog, the tarball URL is different ... Invalid authentication (as an anonymous user) ➤ YN0041: ...
Read more >NPM package feed authentication problem
I try to install packages from the feed and I get this message: " Invalid authentication (as an unknown user)". Any idea on...
Read more >Yarn invalid authentication as an anonymous user
Run yarn npm audit ejsmith03 added the bug label jdanil mentioned this issue ... Anonymous user authentication allows users to log in to...
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 Free
Top 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
I think I have discovered something that can push this forward.
In your GLOBAL
.yarnrc.yml
, you will have your tokens stored. That was my situation:it looks like
npmRegistries["https://npm.pkg.github.com"].npmAuthToken
took priority overnpmScopes.acmeinc.npmAuthToken
.npmRegistries["https://npm.pkg.github.com"].npmAuthToken
did not resolve the issue.npmScopes.acmeinc.npmAuthToken
value tonpmRegistries["https://npm.pkg.github.com"].npmAuthToken
resolved the issue.I’m still not sure, however, why is that and how to resolve this without manually fiddling with configs.
I just had quite a hard time with the authentication part with
Yarn 3.1.0
, but I found the solution to it and hope I can save someone else from the struggles I’ve been having:Problem: My requirements were to publish one repository
@organization/test1
into the GitHub NPM registry. But I was not able to install this package from another repository lying within the same organization, because I defined my.yarnrc.yml
wrongly. Therefore, I received 404 errors and 401 errors when trying to install it.Solution: Here’s what worked for me regarding the
.yarnrc.yml
file: