-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What version of Bun is running?
1.3.1 (89fa0f3)
What platform is your computer?
GitHub Actions (ubuntu-latest)
What steps can reproduce the bug?
- Set up GitHub Actions workflow with Bun 1.3.1
- Create
.npmrcfile with valid NPM token:
- name: Setup npm authentication
run: |
cat > ~/.npmrc << EOF
//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
registry=https://registry.npmjs.org/
always-auth=true
EOF- Verify authentication works with npm:
npm whoami # ✅ Returns username successfully- Try to publish with bun:
bun publish --access public # ❌ Fails with authentication errorWhat is the expected behavior?
bun publish should read the .npmrc file and authenticate successfully, just like npm publish does.
What do you see instead?
error: missing authentication (run `bunx npm login`)
Additional information
What we tried:
- ✅
.npmrcin~/.npmrc- Failed - ✅
.npmrcin project root - Failed - ✅
.npmrcin working directory (packages/core/.npmrc) - Failed - ✅
NPM_CONFIG_TOKENenvironment variable - Failed - ✅
npm_config_//registry.npmjs.org/:_authTokenenvironment variable - Failed
Evidence that authentication is valid:
Running npm whoami before bun publish succeeds and returns the correct username, proving:
- The
.npmrcfile exists and is properly formatted - The NPM_TOKEN is valid
- npm can authenticate successfully
But bun publish immediately after still fails with "missing authentication".
Logs from GitHub Actions:
release Publish to npm npm whoami
release Publish to npm pep <-- ✅ npm authentication works!
release Publish to npm bun publish v1.3.1 (89fa0f34)
release Publish to npm $ bun run build
release Publish to npm ...
release Publish to npm error: missing authentication (run `bunx npm login`) <-- ❌ bun fails
Documentation discrepancy:
The Bun docs state:
"bun publish respects the NPM_CONFIG_TOKEN environment variable"
However, this doesn't appear to work in practice with Bun 1.3.1.
Workaround:
We had to revert to using npm publish instead of bun publish:
- name: Publish to npm
working-directory: ./packages/core
run: npm publish --access publicThis works perfectly with the same .npmrc configuration.
Repository with reproduction:
You can see our full workflow and all attempts at: PepijnSenders/markdown-di#14
Specifically see run logs: https://github.com/PepijnSenders/markdown-di/actions/runs/18837828691
Related issues:
- Support
bun publishauthentication using NPM tokens #16523 (marked as duplicate of NODE_AUTH_TOKEN or NPM_TOKEN support forbun publish#14824) - NODE_AUTH_TOKEN or NPM_TOKEN support for
bun publish#14824
This appears to be an ongoing issue with bun publish authentication in CI environments.