nodejs/node · error · Error
Unknown token id or value "${id}".
Error message
Unknown token id or value "${id}". What it means
Thrown by `npm token rm` when the id neither prefixes any token key nor is prefixed by any token value. The id simply does not correspond to any current auth token.
Source
Thrown at deps/npm/lib/commands/token.js:132
}
const json = this.npm.config.get('json')
const parseable = this.npm.config.get('parseable')
const toRemove = []
log.info('token', `removing ${toRemove.length} tokens`)
const tokens = await paginate('/-/npm/v1/tokens', this.npm.flatOptions)
for (const id of args) {
const matches = tokens.filter(token => token.key.indexOf(id) === 0)
if (matches.length === 1) {
toRemove.push(matches[0].key)
} else if (matches.length > 1) {
throw new Error(
`Token ID "${id}" was ambiguous, a new token may have been created since you last ran \`npm token list\`.`
)
} else {
const tokenMatches = tokens.some(t => id.indexOf(t.token) === 0)
if (!tokenMatches) {
throw new Error(`Unknown token id or value "${id}".`)
}
toRemove.push(id)
}
}
for (const tokenKey of toRemove) {
await otplease(this.npm, this.npm.flatOptions, opts =>
fetch(`/-/npm/v1/tokens/token/${tokenKey}`, {
...opts,
method: 'DELETE',
ignoreBody: true,
})
)
}
if (json) {
output.buffer(toRemove)
} else if (parseable) {
output.standard(toRemove.join('\t'))View on GitHub (pinned to 1b2de5e052)
Solutions
- Re-run `npm token list` to see current valid token ids and copy the exact one.
- Confirm you are authenticated as the token owner and against the correct registry.
- Check for typos and stray whitespace in the id argument.
Example fix
// before npm token rm 00000000-0000-0000 // wrong/expired id // after npm token list // copy exact id, then: npm token rm <exact-id>
Defensive patterns
Strategy: validation
Validate before calling
function findToken(id, tokens) {
const byKey = tokens.filter(t => t.key.indexOf(id) === 0)
if (byKey.length === 1) return byKey[0].key
const byValue = tokens.find(t => id.indexOf(t.token) === 0)
if (byValue) return id
throw new Error(`Unknown token id or value "${id}". Run \`npm token list\` for valid ids.`)
} Prevention
- Copy token ids directly from a fresh `npm token list` output.
- Verify the registry/account matches the token's owner.
- Trim whitespace from copied ids.
When it happens
Trigger: After `matches.length === 0`, the check `tokens.some(t => id.indexOf(t.token) === 0)` is also false — the id is not a known token key prefix nor a known token value prefix.
Common situations: Token already revoked/expired; typo in the id; token belongs to a different account/registry; stale id copied from an old `npm token list`.
Related errors
- Token ID "${id}" was ambiguous, a new token may have been cr
- ${argv[2]} not recognized
- The ${key} option is protected, and cannot be retrieved in t
- You must specify a tag using --tag when publishing a prerele
- You cannot publish over the previously published versions: $
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/9b1b663c594743c9.
Report an issue: GitHub.