GoogleChrome/lighthouse · error

Usage $0 <computed file>

Error message

Usage $0 <computed file>

What it means

Thrown at the top level of assert-baseline-lantern-values-unchanged.js when either the HEAD computed-results file (INPUT_PATH) or the BASELINE_COMPUTED_PATH does not exist on disk. The script compares current Lantern metric values against a checked-in baseline, so both files must be present.

Source

Thrown at core/scripts/lantern/assert-baseline-lantern-values-unchanged.js:23

 * SPDX-License-Identifier: Apache-2.0
 */

import fs from 'fs';
import assert from 'assert/strict';
import path from 'path';

import chalk from 'chalk';

import constants from './constants.js';
import {readJson} from '../../test/test-utils.js';

const INPUT_PATH = process.argv[2] || constants.SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH;
const HEAD_PATH = path.resolve(process.cwd(), INPUT_PATH);
const BASELINE_PATH = constants.BASELINE_COMPUTED_PATH;
const BASELINE_ACCURACY_PATH = constants.BASELINE_ACCURACY_PATH;

if (!fs.existsSync(HEAD_PATH) || !fs.existsSync(BASELINE_PATH)) {
  throw new Error('Usage $0 <computed file>');
}

const computedResults = readJson(HEAD_PATH);
const expectedResults = readJson(BASELINE_PATH);

/** @type {Array<{url: string, maxDiff: number, diffsForSite: Array<DiffForSite>}>} */
const diffs = [];
for (const entry of computedResults.sites) {
  // @ts-expect-error - over-aggressive implicit any on candidate
  const expectedLantern = expectedResults.sites.find(candidate => entry.url === candidate.url);
  const actualLantern = entry.lantern;

  let maxDiff = 0;
  /** @type {DiffForSite[]} */
  const diffsForSite = [];
  Object.keys(actualLantern).forEach(metricName => {
    if (!(metricName in expectedLantern)) throw new Error(`missing metric ${metricName}`);

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Run the Lantern collection/computation step first to produce the computed results JSON at INPUT_PATH.
  2. Verify BASELINE_COMPUTED_PATH (from constants.js) exists in the repo; if missing, regenerate or restore from git.
  3. Pass the correct computed-file path as the first argument, or omit it to use the default.

Example fix

// before
node core/scripts/lantern/assert-baseline-lantern-values-unchanged.js wrong-path.json
// after
npm run lantern-collect && node core/scripts/lantern/assert-baseline-lantern-values-unchanged.js
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function assertInputsExist(headPath, baselinePath) {
  if (!fs.existsSync(headPath) || !fs.existsSync(baselinePath)) {
    console.error('Usage: $0 <computed file>');
    process.exit(1);
  }
}

Prevention

When it happens

Trigger: Running the baseline assertion script before generating the computed results file, or before the baseline has been created; passing a wrong path argument.

Common situations: Running the script on a fresh checkout without building results first; CI job ordering wrong (assertion before generation); typo in the path argument.

Related errors


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