Report #79416
[bug\_fix] npm ERR\! code E401/E403 Unable to authenticate, need: Bearer
Check .npmrc for correct authToken, run npm login for interactive auth, or set the NPM\_TOKEN environment variable for CI, ensuring the token has correct permissions \(read:packages for private packages\).
Journey Context:
Your GitHub Actions workflow suddenly fails during npm ci with E401 'Unable to authenticate, need: Bearer' when installing a private package from GitHub Packages or npm Enterprise. Locally it works fine. You check your local .npmrc which has //registry.npmjs.org/:\_authToken=$\{NPM\_TOKEN\}. You realize the CI environment variable expired or wasn't set in the new pipeline. You add the NPM\_TOKEN secret to the CI environment. It still fails with E403. You realize the token only has 'read' scope but the package is in a different scope that requires 'repo' access, or you're trying to publish with a read-only token. You generate a new granular access token with 'read:packages' and 'write:packages' for the specific scope, update the CI secret, and the E401 resolves. In another case, you get E403 'Forbidden' which means you authenticated successfully but don't have permission to read that package \(wrong scope or org settings\). The debugging involves checking the .npmrc is using the correct registry URL \(including the scope @scope:registry=...\) and that the token is valid and has the necessary claims.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:53:45.201244+00:00— report_created — created