GoogleChrome/lighthouse · error
expected locale file to exist: ${traceEnginePath}
Error message
expected locale file to exist: ${traceEnginePath} What it means
Thrown during locale merging when a locale JSON file is expected to exist in the trace_engine strings directory but is missing on disk. The script iterates locale files and for each expects a corresponding trace_engine locale file; a missing one breaks the merge of trace_engine translations into Lighthouse's locale set.
Source
Thrown at core/scripts/i18n/collect-strings.js:814
const traceEngineStringsDir = `${LH_ROOT}/node_modules/@paulirish/trace_engine/locales`;
const lhStringsDir = `${LH_ROOT}/shared/localization/locales`;
for (const file of glob.sync(`${lhStringsDir}/*.json`)) {
let name = path.basename(file);
if (name.endsWith('.ctc.json')) {
continue;
}
if (name === 'ar-XB.json') {
name = 'ar.json';
}
if (['en-XA.json'].includes(name)) {
continue;
}
const traceEnginePath = `${traceEngineStringsDir}/${name}`;
if (!fs.existsSync(traceEnginePath)) {
throw new Error(`expected locale file to exist: ${traceEnginePath}`);
}
const traceEngineStrings = JSON.parse(fs.readFileSync(traceEnginePath, 'utf-8'));
const strings = JSON.parse(fs.readFileSync(file, 'utf-8'));
for (const [key, value] of Object.entries(traceEngineStrings)) {
const lhKey = `node_modules/@paulirish/trace_engine/${key.replace('.ts', '.js')}`;
// TODO: why is this so malformed? see b/399706272
if (['he.json', 'ru.json', 'ta.json'].includes(name) && lhKey === 'node_modules/@paulirish/trace_engine/generated/Deprecation.js | ObsoleteCreateImageBitmapImageOrientationNone') {
continue;
}
value.message = value.message
.replace(/\\\\/g, '')
.replace(`{imageOrientation: 'from-image'}`, `\\\\{imageOrientation: 'from-image'\\\\}`)
.replace(`{imageOrientation: ''from-image''}`, `\\\\{imageOrientation: ''from-image''\\\\}`)
.replace(`{imageOrientation: "from-image"}`, `\\\\{imageOrientation: "from-image"\\\\}`)
.replace(`{imageOrientation: 'from-image'\\}`, `\\\\{imageOrientation: 'from-image'\\\\}`)View on GitHub (pinned to 9515cd4e58)
Solutions
- Run `npm install` and the relevant build steps to regenerate trace_engine locale files.
- Check if the trace_engine package version in node_modules matches package.json expectations.
- If the locale genuinely doesn't exist in trace_engine yet, add a skip/continue for that locale or wait for the upstream package update.
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
const path = require('path');
function traceEngineLocaleExists(traceEngineStringsDir, name) {
return fs.existsSync(path.join(traceEngineStringsDir, name));
} Try / catch
for (const file of localeFiles) {
const traceEnginePath = `${traceEngineStringsDir}/${name}`;
if (!fs.existsSync(traceEnginePath)) {
console.warn(`Skipping missing trace engine locale: ${traceEnginePath}`);
continue;
}
// ... proceed with merge
} Prevention
- Run `npm install` and build steps before running collect-strings.
- Keep the trace_engine dependency version in sync with what the script expects.
- When adding a new Lighthouse locale, verify trace_engine ships it first.
When it happens
Trigger: Running collect-strings (which produces and merges locale files) when the @paulirish/trace_engine dependency hasn't been fully installed, or when a locale exists in Lighthouse but not yet in trace_engine's generated output.
Common situations: Fresh checkout without `npm install` / `npm run build-all`; trace_engine version bump that removed or renamed a locale; adding a new locale to Lighthouse before trace_engine ships it.
Related errors
- Unsupported locale '${locale}'
- Unsupported locale '${requestedLocale}'
- could not fetch data for locale: ${locale}
- --output-path (${value}) cannot be written to
- Invalid value: Argument 'locale' must be a string
AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13).
Data as JSON: /api/errors/5bb4ea31305c4f35.
Report an issue: GitHub.