Yarn 2 registry and auth are ignored by Lerna
See original GitHub issueI am using monorepo setup based on Yarn 2 (with plug’n’play).
It is possible to set authentication with following in .yarnrc.yml
:
npmPublishRegistry: https://example.com
npmAuthIdent: foo:bar
lerna.json
is as follows:
{
"version": "1.0.0",
"npmClient": "yarn",
"useWorkspaces": true
}
Expected Behavior
Running lerna publish
should just work.
In my case I run package.json
script by yarn like so yarn publish:release
where package.json
has this:
{
"scripts": {
"publish:release": "lerna publish"
}
}
Current Behavior
Error is produced:
lerna http fetch PUT 401 https://example.com/packagename 97ms
lerna ERR! E401 Unable to authenticate, need: BASIC realm="XXX"
Workaround
Put auth and registry directly into command:
yarn publish:release --registry=XXX --legacyAuth=XXX
Which then will forward args to Lerna.
Possible solution
Call Yarn’s publish method that should be aware of auth: https://yarnpkg.com/cli/npm/publish
Your Environment
Executable | Version |
---|---|
lerna --version |
3.20.2 |
npm --version |
6.11.2 |
yarn --version |
2.0.0-rc.29 |
node --version |
12.15.0 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Migrating a monorepo from Lerna to Yarn 3 with PnP and Zero ...
We've been using lerna for our JavaScript monorepo project. ... as if Yarn simply gave up on trying to authenticate me with my...
Read more >Troubleshooting | Lerna
Bootstrap Command · Error when using yarn as an npm client · Private npm registry (Artifactory, npm Enterprise, etc.) integration issues.
Read more >Orchestrating and dockerizing a monorepo with Yarn 3 and ...
//registry.npmjs.org/:_authToken=<YOUR TOKEN>. to npmRegistries: ... Instead, use the following ignore rules: # Yarn .yarn/* !.yarn/patches
Read more >Installing private package from Github Package registry using ...
The following worked for me in .npmrc @mvce-superstars:registry=https://npm.pkg.github.com. Using yarn v2, the following worked for me in ...
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
OP’s current behavior includes the registry set in
.yarnrc.yml
, therefore Lerna somehow takes it into account.I’m working on a monorepo and I’m using
npmScopes
..yarnrc.yml
looks like:When publishing a package within
@xyz
scope, output is:Note that it uses default registry, so it doesn’t seem to care about scope overrides.
Update: just tested with top-level
npmPublishRegistry
, isn’t taken into account neither.I have same issue.
Has this issue not been resolved for over a year?