{"id":"4cf289a68da29bb1","repo":"vitest-dev/vitest","slug":"failed-to-initialize-projects-there-were-errors-d","errorCode":null,"errorMessage":"Failed to initialize projects. There were errors during projects setup. See below for more details.","messagePattern":"Failed to initialize projects\\. There were errors during projects setup\\. See below for more details\\.","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/projects/resolveProjects.ts","lineNumber":391,"sourceCode":"      { root: projectRoot, configFile },\n      path,\n    )))\n  }\n\n  const settled = await Promise.allSettled(promises)\n  const errors: Error[] = []\n  const entries: ResolvedProjectEntry[] = []\n  for (const result of settled) {\n    if (result.status === 'rejected') {\n      errors.push(result.reason)\n    }\n    else {\n      entries.push(result.value)\n    }\n  }\n\n  if (errors.length) {\n    throw new AggregateError(\n      errors,\n      'Failed to initialize projects. There were errors during projects setup. See below for more details.',\n    )\n  }\n\n  return flattenContainerEntries(context, entries)\n}\n\n/**\n * Replace container entries (file-based configs that declare `projects`) with\n * the projects they declare, recursively. A container behaves like the root\n * config: it doesn't run tests and never gets a Vite server; its projects\n * extend it by default and their names are prefixed with the container's name.\n */\nasync function flattenContainerEntries(\n  context: ProjectsResolutionContext,\n  entries: ResolvedProjectEntry[],\n): Promise<ResolvedProjectEntry[]> {","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/node/projects/resolveProjects.ts#L373-L409","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// reading the aggregate to find root causes\ntry {\n  await createVitest('test', cliOptions)\n} catch (e) {\n  if (e instanceof AggregateError) {\n    for (const inner of e.errors) console.error(inner)\n  }\n  throw e\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isAggregateError(e: unknown): e is AggregateError {\n  return e instanceof Error && Array.isArray((e as any).errors)\n}","tryCatchPattern":"try {\n  await createVitest('test', cliOptions)\n} catch (e) {\n  if (e instanceof AggregateError) {\n    console.error('Project init failed:')\n    for (const inner of e.errors) console.error(' -', inner.message)\n  }\n  throw e\n}","preventionTips":["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."],"tags":["projects","aggregate-error","configuration","initialization","diagnostics"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}