vitest-dev/vitest · error · AggregateError
Failed to initialize projects. There were errors during proj
Error message
Failed to initialize projects. There were errors during projects setup. See below for more details.
What it means
resolveDeclaredProjectEntries (resolveProjects.ts:378-395) resolves every declared project in parallel via Promise.allSettled and collects rejections. If any rejection occurred, it throws an AggregateError wrapping all of them with this summary message. The individual causes (visible in error.cause / the aggregate's errors array) are the real problems.
Source
Thrown at packages/vitest/src/node/projects/resolveProjects.ts:391
{ root: projectRoot, configFile },
path,
)))
}
const settled = await Promise.allSettled(promises)
const errors: Error[] = []
const entries: ResolvedProjectEntry[] = []
for (const result of settled) {
if (result.status === 'rejected') {
errors.push(result.reason)
}
else {
entries.push(result.value)
}
}
if (errors.length) {
throw new AggregateError(
errors,
'Failed to initialize projects. There were errors during projects setup. See below for more details.',
)
}
return flattenContainerEntries(context, entries)
}
/**
* Replace container entries (file-based configs that declare `projects`) with
* the projects they declare, recursively. A container behaves like the root
* config: it doesn't run tests and never gets a Vite server; its projects
* extend it by default and their names are prefixed with the container's name.
*/
async function flattenContainerEntries(
context: ProjectsResolutionContext,
entries: ResolvedProjectEntry[],
): Promise<ResolvedProjectEntry[]> {View on GitHub (pinned to d568f8ce37)
Solutions
- Read the AggregateError's `errors` array (or print error.cause) to find each individual failure.
- Fix the underlying per-project error (install missing dep, fix syntax, correct extends path).
- Temporarily isolate the failing project with --project=<others> to confirm the rest resolve.
- If many errors, fix them top-to-bottom; later errors often cascade from the first.
Example fix
// reading the aggregate to find root causes
try {
await createVitest('test', cliOptions)
} catch (e) {
if (e instanceof AggregateError) {
for (const inner of e.errors) console.error(inner)
}
throw e
} Defensive patterns
Strategy: try-catch
Type guard
function isAggregateError(e: unknown): e is AggregateError {
return e instanceof Error && Array.isArray((e as any).errors)
} Try / catch
try {
await createVitest('test', cliOptions)
} catch (e) {
if (e instanceof AggregateError) {
console.error('Project init failed:')
for (const inner of e.errors) console.error(' -', inner.message)
}
throw e
} Prevention
- Always unwrap AggregateError to find the real per-project failures.
- Run a single project with --project to isolate which config is broken.
- Validate each workspace project's config file loads standalone before combining.
When it happens
Trigger: One or more project config files fail to load (syntax error, missing dependency, invalid vite config); an extends target doesn't exist; a plugin throws during config resolution; a directory project's vite resolve fails.
Common situations: A workspace project imports a package not installed in that workspace; a vitest.config.ts has a TypeScript/syntax error; an `extends` path is wrong; a plugin version mismatch throws during config; one bad project in a monorepo blocks the whole run.
Related errors
- Project "${name}" was not found.
- Project name "${name}" is not unique. All projects should ha
- Project name "${name}"${entryFile ? ` from "${entryFile}"` :
- No projects were found. Make sure your configuration is corr
- Found a circular "projects" definition: ${[...chain, realCon
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/4cf289a68da29bb1.json.
Report an issue: GitHub.