berry icon indicating copy to clipboard operation
berry copied to clipboard

[Feature] `yarn npm publish` should print registry URL where it is publishing

Open earshinov opened this issue 2 years ago • 6 comments

  • [ ] I'd be willing to implement this feature (contributing guide)
  • [x] This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

I just spent another hour trying to publish my package with yarn 4 instead of npm, because I want workspace: cross-references in package.json to be properly handled.

With npm I had:

package.json:

  "publishConfig": {
    "@earshinov:registry": "https://private-registry/packages/npm/"
  }

.npmrc:

//private-registry/packages/npm/:_authToken=$CI_JOB_TOKEN

With Yarn, I had to figure out:

  1. Does Yarn look into .npmrc? Apparently, the answer is Yes for Yarn Classic and No for Yarn Berry (or maybe they just don't handle these particular kinds of keys).

  2. How do I give the auth token then? Apparently, that's yarn config set _authToken "$CI_JOB_TOKEN" for Yarn classic (found on GitHub) and yarn config set 'npmRegistries["//private-registry"].npmAuthToken' "$CI_JOB_TOKEN" for Yarn Berry (thanks for this useful example in yarn config set docs, by the way!).

  3. Now I am still facing YN0033: No authentication configured for request when running yarn npm publish, and have no idea if I misconfigured the token or the registry URL. And yarn npm publish has no verbosity flags.

If yarn npm publish printed the registry URL it is accessing, it would help.

Describe the solution you'd like

A log line similar to YN00xx: Publishing to npm.example.com

Describe the drawbacks of your solution

None?

Describe alternatives you've considered

  • Let developers continue spending time to figure out what's wrong with their project configuration. May be a feasible option, because apparently I am the only one having problems with it as I don't see any similar reports.

earshinov avatar Mar 30 '24 17:03 earshinov

Maybe via a verbose flag ? Most of users probably publish to standard public npmjs.com

MathRobin avatar Dec 31 '24 11:12 MathRobin

I have the same problem, YN0033: No authentication configured for request.

LvChengbin avatar Jan 07 '25 08:01 LvChengbin

For future readers, some things to double-check:

a. Are you running yarn config set properly? Either of these should work:

# Entire URL
NPM_REGISTRY="$(node -p 'Object.values(require("./package.json").publishConfig)[0]')"
yarn config set "npmRegistries['$NPM_REGISTRY'].npmAuthToken" "$CI_JOB_TOKEN"
# '//' + domain name
yarn config set 'npmRegistries["//private-registry"].npmAuthToken' "$CI_JOB_TOKEN"

b. Your publishConfig can't have scope. In contrast to npm, Yarn doesn't seem to support that.

❌

"publishConfig": {
  "@your-package-scope:registry": "https://private-registry/packages/npm/"
}

✅

"publishConfig": {
  "registry": "https://private-registry/packages/npm/"
}

earshinov avatar Jan 07 '25 13:01 earshinov

@LvChengbin , double-check your publishConfig. It was the reason why it wasn't working for me.

earshinov avatar Jan 07 '25 13:01 earshinov

Hi, I'd like to work on this issue. Is it still available?

KyeongJooni avatar Dec 12 '25 15:12 KyeongJooni

@KyeongJooni

Yes. For the most part, we don't assign issues or do "availability" here. Just find something you are interested to work on and submit PRs. Do note that the yarn team is run by volunteers so it may take some time before we get around to reviews.

You can collaborate with other contributors here on GitHub. If you have any questions you can find us on Discord or GitHub.

clemyan avatar Dec 17 '25 11:12 clemyan