Lesstep
GitHub Actions · npm · Checked November 3, 2026

GitHub Actions: npm publish fails with "ENEEDAUTH"

With no npm token in the job, npm publish relies on trusted publishing: npm asks GitHub for an OIDC token and trades it at the registry for a short-lived publish token. If any part of that fails, npm does not say so at the default log level. It goes on without credentials and stops at "need auth". The error is the symptom; the reason is in a log line you have to ask for.

What it looks like

npm error code ENEEDAUTH
npm error need auth This command requires you to be logged in to https://registry.npmjs.org/
npm error need auth You need to authorize this machine using `npm adduser`

Make npm print the reason

npm's lib/utils/oidc.js never fails the command. Each way it can give up is one log line at verbose or silly. Run the publish once with:

- run: npm publish --loglevel silly

and look for the lines with oidc:

Several projects added --loglevel verbose for this after a refused exchange (duskfleet #314, agentboard #71). verbose shows the registry's reason but not the missing permission, which is only at silly.

1. npm is older than 11.5.1

npm's documentation: trusted publishing "requires npm CLI version 11.5.1 or later and Node version 22.14.0 or higher." The Ubuntu 24.04 runner image comes with Node.js 22.23.4 and npm 10.9.9, and node-version: '22' in setup-node also gives npm 10. A job that does not set up Node 24 publishes with an npm that never tries. In homeboy's release action, Node setup was skipped for components that declared no Node version, and those publishes failed with ENEEDAUTH (#17247).

- uses: actions/setup-node@v7
  with:
    node-version: '24'
- run: npm --version
- run: npm publish

Or keep the Node version and run npm install -g npm@latest before publishing.

2. No id-token: write

Without it, GitHub gives the job no way to ask for an OIDC token. A permissions: block on the job replaces the workflow's, so the publish job needs it in its own block if it has one. When the publish runs in a reusable workflow, npm's documentation says the permission "must also be given to both parent and child workflows."

permissions:
  contents: read
  id-token: write

3. The trusted publisher does not match the run

npm checks the run against what you entered in the package's settings on npmjs.com, and it does not check the entry when you save it. All fields are case-sensitive.

4. A self-hosted runner

npm's documentation: "Self-hosted runners are not currently supported but are planned for future releases." Publish from a GitHub-hosted runner, or use a token there.

Telling it apart

See failed jobs from IntelliJ IDEA

Pipeline Inbox for GitHub Actions Workflows, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the runs of all your repositories in an IDE tool window, with their jobs and steps, and your current branch's runs are in the status bar. Reading is free; re-running failed jobs, cancelling, running workflows and reviewing deployments are Pro (US$1.50 a month, with a 30-day trial).

GitHub and GitHub Actions are trademarks of GitHub, Inc.; npm is a trademark of npm, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with, sponsored or endorsed by GitHub, Inc., npm, Inc. or JetBrains.

More: AWS: "Not authorized to perform sts:AssumeRoleWithWebIdentity" · "Node.js 20 is deprecated" · "Input required and not supplied" · GitHub Actions plugins for IntelliJ IDEA compared · 日本語