nodejs/node · warning · Error
User cancelled operation
Error message
User cancelled operation
What it means
Thrown by TrustCommand.confirmOperation when the `yes` config resolves to exactly `false`, i.e. the user explicitly passed `--no-yes` (or `--yes=false`). This is the non-interactive hard-decline path: rather than prompting, it aborts immediately. It is distinct from the interactive 'typed n' case (also 'User cancelled operation' but at line 165).
Source
Thrown at deps/npm/lib/trust-cmd.js:156
}
if (urlLines.length > 0) {
output.standard()
output.standard(urlLines.join('\n'), { [META]: true, redact: false })
}
}
if (pad) {
output.standard()
}
}
}
async confirmOperation (yes) {
// Ask for confirmation unless --yes flag is set
if (yes === true) {
return
}
if (yes === false) {
throw new Error('User cancelled operation')
}
const confirm = await input.read(
() => _read({ prompt: 'Do you want to proceed? (y/N) ', default: 'n' })
)
const normalized = confirm.toLowerCase()
if (['y', 'yes'].includes(normalized)) {
return
}
throw new Error('User cancelled operation')
}
getFrontendUrl ({ pkgName }) {
if (this.registryIsDefault) {
return new URL(`/package/${pkgName}`, NPM_FRONTEND).toString()
}
return null
}
View on GitHub (pinned to 1b2de5e052)
Solutions
- Pass `--yes` (or `-y`) to auto-confirm, or omit `--no-yes` to get the interactive prompt.
- Use `--dry-run` to preview without confirming if you only wanted to inspect.
- Remove `yes=false` from .npmrc / environment if it was unintended.
Example fix
// before npm trust gitlab --file .gitlab-ci.yml --project g/p --allow-publish --no-yes // after npm trust gitlab --file .gitlab-ci.yml --project g/p --allow-publish --yes
Defensive patterns
Strategy: validation
Validate before calling
if (config.get('yes') === false) {
throw new Error('--no-yes blocks confirmation; pass --yes or omit --no-yes')
} Type guard
const isExplicitNoYes = (cfg) => cfg.get('yes') === false Try / catch
try {
await createConfigCommand(...)
} catch (err) {
if (err.message === 'User cancelled operation' && yesFlag === false) {
// treat as intentional abort; do not retry
} else { throw err }
} Prevention
- Do not pass --no-yes unless you intend to forbid the operation outright.
- In automation use --yes to skip prompts, or omit it for an interactive prompt.
- Audit .npmrc for `yes=false`.
When it happens
Trigger: Running `npm trust gitlab ... --no-yes`, or having `yes=false` in config/env, against a create/revoke flow that calls confirmOperation. The check `if (yes === false)` short-circuits before the prompt.
Common situations: Automation that deliberately sets --no-yes to forbid mutations; a wrapper script that injects --no-yes; conflicting CI config setting npm_config_yes=false.
Related errors
- ${this.constructor.providerEntity} must be specified in the
- GitLab CI/CD pipeline file must be just a file not a path
- Package name must be specified either as an argument or in t
- Package name must be specified either as an argument or in t
- ID of the trusted relationship to revoke must be specified w
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/4d25d9a9157e3d9d.
Report an issue: GitHub.