withastro/astro · error · AggregateError
${cssTransformErrors[0].message}
Error message
${cssTransformErrors[0].message} What it means
After the compiler runs, Astro processes `<style>` blocks and may produce CSS transform errors. If exactly one error exists it is re-thrown directly; if multiple exist they are wrapped in an `AggregateError` carrying all errors. This error has no static `code` — it surfaces the first CSS error's message. It represents a failure in transforming the CSS layer of an `.astro` component.
Source
Thrown at packages/astro/src/core/compile/compile.ts:119
name: 'CompilerError',
message: compilerError.text,
location: {
line: compilerError.labels[0].line,
column: compilerError.labels[0].column,
file: filename,
},
hint: compilerError.hint,
});
}
switch (cssTransformErrors.length) {
case 0:
break;
case 1: {
throw cssTransformErrors[0];
}
default: {
throw new AggregateError({
...cssTransformErrors[0],
errors: cssTransformErrors,
});
}
}
}
function normalizeFilename(filename: string, root: URL) {
const normalizedFilename = normalizePath(filename);
const normalizedRoot = normalizePath(fileURLToPath(root));
if (normalizedFilename.startsWith(normalizedRoot)) {
return normalizedFilename.slice(normalizedRoot.length - 1);
} else {
return normalizedFilename;
}
}
View on GitHub (pinned to d081033d5f)
Solutions
- Inspect the surfaced CSS error message and fix the offending `<style>` block.
- If an `AggregateError`, iterate `.errors` to see every failing rule.
- Validate the CSS in isolation (e.g., paste into a linter) to catch syntax issues faster.
- Check for a recent CSS tooling upgrade that changed validation strictness.
Defensive patterns
Strategy: try-catch
Type guard
function isCssAggregate(e) { return e instanceof AggregateError && Array.isArray(e.errors); } Try / catch
try {
await build();
} catch (e) {
const errs = e instanceof AggregateError ? e.errors : [e];
for (const err of errs) { /* report CSS error */ }
} Prevention
- Lint component <style> blocks with a CSS linter.
- Validate CSS in isolation when an error message points to a style block.
- Track CSS tooling upgrades that tighten validation.
When it happens
Trigger: An `.astro` component's `<style>` block contains CSS that fails the transform pipeline (e.g., invalid syntax caught by the CSS processor, or a preprocessing error). Multiple style errors in one component produce the `AggregateError` branch at `compile.ts:119`.
Common situations: Invalid CSS property values, unterminated declarations, unsupported `@import`, or a PostCSS/Lightning CSS transform rejecting the stylesheet; upgrading a CSS tool that newly rejects previously-tolerated input.
Related errors
- UnknownCompilerError
- CompilerError
- [RSS] You can only glob entries within 'src/pages/' when pas
- [astro:actions] `defineAction()` unexpectedly used on the cl
- [astro:actions] `getActionContext()` unexpectedly used on th
AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12).
Data as JSON: /api/errors/d2bba9013037c4d0.
Report an issue: GitHub.