[BUG] Publishing denied for 2FA reasons despite "Bypass 2FA" tokens
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
This appears to be unrelated to https://github.com/npm/cli/issues/8869 despite the name of the issue reflecting the problem presented here.
I am attempting to publish my first package. My account does not have 2FA set up, I do not own a physical device with which to set up 2FA and the browser website only allows physical keys to be used to set up 2FA. I have followed the token creation steps as laid out in the documentation. When I run npm token list --json I can see two tokens, both of which should allow the bypassing of 2FA in publishing:
[
{
"name": REDACTED,
"description": REDACTED,
"key": REDACTED,
"token": REDACTED,
"expiry": "2026-04-29T14:11:13.703Z",
"cidr": [],
"bypass_2fa": true,
"revoked": null,
"created": "2026-04-22T14:11:13.713Z",
"updated": "2026-04-22T14:11:13.713Z",
"accessed": null,
"permissions": [
{
"name": "package",
"action": "write"
}
],
"scopes": [
{
"name": null,
"type": "package"
}
]
},
{
"name": REDACTED,
"description": REDACTED,
"key": REDACTED,
"token": REDACTED,
"expiry": "2026-07-21T13:34:42.483Z",
"cidr": [],
"bypass_2fa": true,
"revoked": null,
"created": "2026-04-22T13:34:42.536Z",
"updated": "2026-04-22T13:34:42.536Z",
"accessed": null,
"permissions": [
{
"name": "package",
"action": "write"
}
],
"scopes": [
{
"name": REDACTED,
"type": "package"
}
]
}
]
Instead, when I run npm publish --access public, I get the following logs:
npm error code E403
npm error 403 403 Forbidden - PUT https://registry.npmjs.org/@<my NPM username>%2ftest - Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages.
npm error 403 In most cases, you or one of your dependencies are requesting
npm error 403 a package version that is forbidden by your security policy, or
npm error 403 on a server you do not have access to.
with my NPM username redacted here.
I will note that whilst the website gave me the tokens when I created them, I have not needed to paste them verbatim anywhere.
Expected Behavior
I would expect this process to publish the package, per https://docs.npmjs.com/creating-and-publishing-scoped-public-packages.
Steps To Reproduce
- In a new directory,
npm init(npm init --scoped=@<your NPM username>can be used here but it does not appear to change anything). - Specify the package name
@<your NPM username>/testand set the version to0.0.0and choose defaults for other properties. - Create a simple
index.jsfile containingconsole.log("hello world");. npm loginand use the browser to log your account in.- If you do not already have one, create an access token in your NPM account that is scoped to your username. This should have "bypass 2FA" ticked.
- For good measure, if you do not already have one, create another access token that has no scoping. This also should have "bypass 2FA" ticked.
- Check that
npm token list --jsonreturns logs at least similar to what is presented in the "Current Behaviour" section of this report. npm publish --access public
Environment
- npm: v11.12.1 (issue originally made for v10.9.3 but v11.12.1 has been tested as not working)
- Node.js: v22.18.0
- OS Name: Kubuntu Questing
- System Model Name: PC
- npm config: unchanged from defaults
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names no source file or test. Start by reproducing the failure with npm login, npm token list --json, and npm publish --access public using the reported npm and Node.js versions; compare the bypass_2fa token data with the registry's E403 response. Done means the documented token setup successfully publishes the scoped public package.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- authentication, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100