GoogleChrome/lighthouse · error · Error

"${str}" is not a valid 'output' value. Argument 'output' mu

Error message

"${str}" is not a valid 'output' value. Argument 'output' must be an array from choices "json", "html", "csv"

What it means

After confirming all --output values are strings, coerceOutput splits on commas and checks each individual value against the allowed set ['json', 'html', 'csv']. This error fires for a specific invalid string value, naming it in the message. It is the more common and more user-friendly sibling of error 3.

Source

Thrown at cli/cli-flags.js:399

  return value;
}

/**
 * Coerce output CLI input to `LH.SharedFlagsSettings['output']` or throw if not possible.
 * @param {Array<unknown>} values
 * @return {Array<LH.OutputMode>}
 */
function coerceOutput(values) {
  const outputTypes = ['json', 'html', 'csv'];
  const errorHint = `Argument 'output' must be an array from choices "${outputTypes.join('", "')}"`;
  if (!values.every(item => typeof item === 'string')) {
    throw new Error('Invalid values. ' + errorHint);
  }
  // Allow parsing of comma-separated values.
  const strings = values.flatMap(value => value.split(','));
  const validValues = strings.filter(/** @return {str is LH.OutputMode} */ str => {
    if (!outputTypes.includes(str)) {
      throw new Error(`"${str}" is not a valid 'output' value. ` + errorHint);
    }
    return true;
  });

  return validValues;
}

/**
 * Verifies outputPath is something we can actually write to.
 * @param {unknown=} value
 * @return {string=}
 */
function coerceOutputPath(value) {
  if (value === undefined) return;

  if (typeof value !== 'string' || !value || !fs.existsSync(path.dirname(value))) {
    throw new Error(`--output-path (${value}) cannot be written to`);
  }

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Use one of the three valid values: json, html, or csv (lowercase only)
  2. For multiple formats, use comma separation with valid values: --output=json,html
  3. Check for typos and case sensitivity in the format name

Example fix

# before
lighthouse --output=JSON --output=htm https://example.com
# after
lighthouse --output=json --output=html https://example.com
Defensive patterns

Strategy: validation

Validate before calling

// Validate output format choices before running
const VALID_OUTPUTS = ['json', 'html', 'csv'];
function validateOutputFormats(values) {
  const formats = values.flatMap(v => v.split(','));
  for (const f of formats) {
    if (!VALID_OUTPUTS.includes(f)) {
      throw new Error(`Invalid output format: ${f}. Valid: ${VALID_OUTPUTS.join(', ')}`);
    }
  }
}

Prevention

When it happens

Trigger: Passing --output with a string value that is not 'json', 'html', or 'csv'. For example: --output=xml, --output=pdf, --output=JSON (case-sensitive), or a comma-separated list containing a typo like --output=json,htm.

Common situations: Typing a format name incorrectly (htm instead of html); using wrong case (JSON instead of json); requesting an unsupported format like xml or pdf; copy-paste errors in scripts.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/8ae91877bfad8764. Report an issue: GitHub.