Skip to content

bin: publish to registry.npmjs.org regardless of yarn's environment - #295

Merged
gnidan merged 1 commit into
mainfrom
build-publish-registry
Sep 16, 2026
Merged

gnidan merged 1 commit into
mainfrom
build-publish-registry

Conversation

@gnidan

@gnidan gnidan commented Sep 16, 2026

Copy link
Copy Markdown
Member

The first real publish run sent npm publish to
registry.yarnpkg.com and failed with ENEEDAUTH. publish.yml
runs the script through yarn tsx, and Yarn 1 injects
npm_config_registry (and other npm_config_* variables) pointing
at its own mirror into the environment of any script it runs; npm view and npm publish inherited that and talked to the mirror
instead 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.ts run for the same reason: a user's npm token
is scoped to registry.npmjs.org, not the mirror.

Both spawns now pass --registry https://registry.npmjs.org
explicitly and run with an environment stripped of every
npm_config_* key (case-insensitively), via a new npmEnv helper,
so Yarn's injected registry override can no longer reach either
call. npm pack in bin/packlist.ts was never affected, since
packing doesn't talk to a registry.

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.
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-16 21:05 UTC

@gnidan
gnidan merged commit cc83536 into main Sep 16, 2026
5 checks passed
@gnidan
gnidan deleted the build-publish-registry branch September 16, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant