webpack/webpack · error · Error

${failed} examples failed

Error message

${failed} examples failed

What it means

examples/buildAll.js iterates every example directory and runs `node build.js` in each via child_process.execSync, catching per-example failures. After the loop it throws an aggregate error naming how many examples failed. The real failures are logged to stdout (the caught err objects) above this throw, so this error is the summary, not the root cause.

Source

Thrown at examples/buildAll.js:28

let failed = 0;
let i = 0;

for (const cmd of commands) {
	console.log(`[${++i}/${commands.length}] ${cmd}`);

	try {
		cp.execSync(cmd, { encoding: "utf8" });
	} catch (err) {
		failed++;
		console.log(err);
	}
}

console.log("done");

if (failed > 0) {
	throw new Error(`${failed} examples failed`);
}

View on GitHub (pinned to 318421ea8a)

Solutions

  1. Read the console output immediately above the throw — each failed example's full execSync error is printed there.
  2. Reproduce the failing example in isolation: `cd examples/<name> && node build.js`.
  3. Fix the root cause in the example config or webpack core, then re-run the whole pipeline.
  4. If the failure is an expected stats/output change, regenerate example snapshots/expected output and re-run.

Example fix

// before
throw new Error(`${failed} examples failed`);

// after (diagnostic): surface which examples failed
if (failed > 0) {
  throw new Error(`${failed} examples failed: ${failedNames.join(', ')}`);
}
Defensive patterns

Strategy: try-catch

Try / catch

// wrap each example build and record which failed, so the aggregate error is actionable
const failedNames = [];
for (const cmd of commands) {
  try { cp.execSync(cmd, { encoding: 'utf8' }); }
  catch (err) { failed++; failedNames.push(cmd); console.error(err); }
}
if (failed > 0) throw new Error(`${failed} examples failed: ${failedNames.join(', ')}`);

Prevention

When it happens

Trigger: Running `node examples/buildAll.js` (or the `yarn build:examples` pipeline) when one or more example builds exit non-zero — e.g. a snapshot mismatch, a core webpack change that alters emitted output, or a broken example config.

Common situations: A webpack core change that changes emitted stats/output shape breaks many examples at once; outdated snapshots after an intentional stats change; an example depending on a feature that was removed; flaky examples failing under memory pressure.

Related errors


AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03). Data as JSON: /data/errors/d1a523d7a16a2030.json. Report an issue: GitHub.