{"record":{"id":"119bbf7f5db0284b","repo":"yarnpkg/yarn","slug":"noninteractivenotoken","errorCode":null,"errorMessage":"nonInteractiveNoToken","messagePattern":"nonInteractiveNoToken","errorType":"exception","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/cli/commands/login.js","lineNumber":75,"sourceCode":"    config.registries.npm.setToken(auth);\n    return function revoke(): Promise<void> {\n      reporter.info(reporter.lang('notRevokingConfigToken'));\n      return Promise.resolve();\n    };\n  }\n\n  const env = process.env.YARN_AUTH_TOKEN || process.env.NPM_AUTH_TOKEN;\n  if (env) {\n    config.registries.npm.setToken(`Bearer ${env}`);\n    return function revoke(): Promise<void> {\n      reporter.info(reporter.lang('notRevokingEnvToken'));\n      return Promise.resolve();\n    };\n  }\n\n  // make sure we're not running in non-interactive mode before asking for login\n  if (flags.nonInteractive || config.nonInteractive) {\n    throw new MessageError(reporter.lang('nonInteractiveNoToken'));\n  }\n\n  //\n  const creds = await getCredentials(config, reporter);\n  if (!creds) {\n    reporter.warn(reporter.lang('loginAsPublic'));\n    return function revoke(): Promise<void> {\n      reporter.info(reporter.lang('noTokenToRevoke'));\n      return Promise.resolve();\n    };\n  }\n\n  const {username, email} = creds;\n  const password = await reporter.question(reporter.lang('npmPassword'), {\n    password: true,\n    required: true,\n  });\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/cli/commands/login.js#L57-L93","documentation":"During login, yarn first checks the YARN_AUTH_TOKEN / NPM_AUTH_TOKEN env vars (login.js:71-74); if absent and the process is non-interactive (flags.nonInteractive or config.nonInteractive, login.js:78) it cannot prompt for credentials and throws nonInteractiveNoToken.","triggerScenarios":"Running `yarn login --nonInteractive` in CI without an auth token env var; any login attempt in a detached/TTY-less environment where config.nonInteractive auto-activates and no token env var is present.","commonSituations":"CI pipelines (GitHub Actions, Jenkins) that forgot to expose the npm token; Docker builds with no TTY; scripts that pass --nonInteractive but rely on interactive prompt.","solutions":["Export an auth token: `export NPM_AUTH_TOKEN=<token>` (or YARN_AUTH_TOKEN) in the environment.","Configure an .npmrc with `//registry.npmjs.org/:_authToken=<token>` for the CI runner.","Drop --nonInteractive and run in an interactive shell so the prompt can collect credentials.","For publish in CI prefer a pre-provisioned token over `yarn login`."],"exampleFix":"# before\n$ yarn login --nonInteractive   # throws nonInteractiveNoToken\n# after (CI)\n$ export NPM_AUTH_TOKEN=npm_xxx\n$ yarn login --nonInteractive","handlingStrategy":"validation","validationCode":"function ensurePublishToken() {\n  const token = process.env.YARN_AUTH_TOKEN || process.env.NPM_AUTH_TOKEN;\n  const interactive = process.stdout.isTTY;\n  if (!token && !interactive) {\n    throw new Error('No auth token and no TTY: set NPM_AUTH_TOKEN or run interactively.');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runYarn(['login', '--nonInteractive']);\n} catch (e) {\n  if (/nonInteractiveNoToken/.test(e.message)) {\n    console.error('CI auth missing: export NPM_AUTH_TOKEN before publishing.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Provision NPM_AUTH_TOKEN/YARN_AUTH_TOKEN in CI secrets for every publish job.","Fail fast in pipelines: assert the token env var exists before invoking yarn.","Prefer a pre-baked .npmrc over interactive login in automation."],"tags":["cli","auth","ci","non-interactive","registry"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}