berry: [Bug] YN0041: Invalid authentication after logging in with `yarn npm login`
- 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
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 25 (9 by maintainers)
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"].npmAuthTokentook priority overnpmScopes.acmeinc.npmAuthToken.npmRegistries["https://npm.pkg.github.com"].npmAuthTokendid not resolve the issue.npmScopes.acmeinc.npmAuthTokenvalue tonpmRegistries["https://npm.pkg.github.com"].npmAuthTokenresolved the issue.I’m still not sure, however, why is that and how to resolve this without manually fiddling with configs.
I’m getting reports from multiple colleagues working in multiple projects that they are unable to log in using
yarn npm login, using Yarn 2.4 and 3.0.The only workaround that seems to be working is adding this in your command line configuration file (.bashrc or .zshrc, depending on your setup):
but that works only if you need one auth token.
How can I help you resolving this, and how can I help my colleagues?
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/test1into 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.ymlwrongly. Therefore, I received 404 errors and 401 errors when trying to install it.Solution: Here’s what worked for me regarding the
.yarnrc.ymlfile:I am also having the same issue. I was also able to successfully login. Even after successful login, I see the below error. I use jfrog, out private repository
UnhandledPromiseRejectionWarning: Error: rxjs@npm:6.6.2: Invalid authentication (as an anonymous user)
Is there an official solution to this issue? I think this issue should be reopen. I’m still struggling with
yarn npm login --scope myorgandyarn npm --scope myorg. It doesn’t work by default without manually modifying the global.yarnrc.ymlfile in my home folderDue to the lack of feedback i’ll close this under the assumption that what is actually happening is that you’re trying to publish an already existing version, which V2.3 will show better error messages for thanks to https://github.com/yarnpkg/berry/pull/1809
I have same issue =(
yarn npm loginsuccessfully logged in, butyarn npm publishisInvalid authentication (as undefined)Here my
.yarnrc.ymlOne solution I found, that solved it for me was to use the following
.yarnrc.ymlfile and then runyarn npm login -s myPrivatePackageNameWithoutTheAtto login.Using
yarn 3.2.1Yep, @paul-soporan investigated a bit and it seems that any 403 (which is what the server answers) are reported as
Invalid authentication- plus a missing option in one of the calls that caused theas undefined. We’ll fix both issues!