Repository navigation
bin: publish to registry.npmjs.org regardless of yarn's environment - #295
Merged
Merged
Conversation
Yarn 1 injects npm_config_registry (and other npm_config_* vars) pointing at registry.yarnpkg.com into the environment of any script it runs. bin/publish-tagged.ts spawns npm view and npm publish, which inherited that env and, in the first real CI run, sent npm publish to the yarnpkg mirror instead of registry.npmjs.org. That mirror has no OIDC trust and no token, so the publish failed with ENEEDAUTH. The same injection breaks a local yarn tsx run, since a user's npm token is scoped to registry.npmjs.org. Both npm view and npm publish now pass --registry https://registry.npmjs.org explicitly and run with an env stripped of every npm_config_* key (case-insensitively), so yarn's injected registry override can no longer reach either spawn.
Contributor
|
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first real publish run sent
npm publishtoregistry.yarnpkg.comand failed withENEEDAUTH.publish.ymlruns the script through
yarn tsx, and Yarn 1 injectsnpm_config_registry(and othernpm_config_*variables) pointingat its own mirror into the environment of any script it runs;
npm viewandnpm publishinherited that and talked to the mirrorinstead of npmjs.org. OIDC trusted publishing only exists on
registry.npmjs.org, so the mirror had no trust and no token to fall
back on. The same injection breaks a local
yarn tsx bin/publish-tagged.tsrun for the same reason: a user's npm tokenis scoped to registry.npmjs.org, not the mirror.
Both spawns now pass
--registry https://registry.npmjs.orgexplicitly and run with an environment stripped of every
npm_config_*key (case-insensitively), via a newnpmEnvhelper,so Yarn's injected registry override can no longer reach either
call.
npm packinbin/packlist.tswas never affected, sincepacking doesn't talk to a registry.