Skip to content

bun publish fails with authentication error despite valid .npmrc in GitHub Actions #24124

@PepijnSenders

Description

@PepijnSenders

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?

  1. Set up GitHub Actions workflow with Bun 1.3.1
  2. Create .npmrc file 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
  1. Verify authentication works with npm:
npm whoami  # ✅ Returns username successfully
  1. Try to publish with bun:
bun publish --access public  # ❌ Fails with authentication error

What 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:

  1. .npmrc in ~/.npmrc - Failed
  2. .npmrc in project root - Failed
  3. .npmrc in working directory (packages/core/.npmrc) - Failed
  4. NPM_CONFIG_TOKEN environment variable - Failed
  5. npm_config_//registry.npmjs.org/:_authToken environment variable - Failed

Evidence that authentication is valid:

Running npm whoami before bun publish succeeds and returns the correct username, proving:

  • The .npmrc file 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 public

This 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:

This appears to be an ongoing issue with bun publish authentication in CI environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun installSomething that relates to the npm-compatible client

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions