{"record":{"id":"f766d446df79aaac","repo":"vitest-dev/vitest","slug":"root-path-does-not-exist-or-is-not-a-directory","errorCode":null,"errorMessage":"Root path does not exist or is not a directory: ${resolved.root}","messagePattern":"Root path does not exist or is not a directory: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/config/resolveConfig.ts","lineNumber":250,"sourceCode":"    viteConfig.test as UserConfig | undefined,\n  )\n\n  const resolved = deepMerge({}, configDefaults, options) as ResolvedConfig\n  resolved.root = viteConfig.root\n  resolved.providedOptions = providedOptions\n\n  // These options are resolved once for the whole run using the root config.\n  // Coverage is shared by reference: each project's setup/test/config files are\n  // appended to the same exclude list below, keeping them out of the report.\n  if (globalConfig) {\n    resolved.coverage = globalConfig.coverage\n    resolved.attachmentsDir = globalConfig.attachmentsDir\n    resolved.mergeReportsLabel = globalConfig.mergeReportsLabel\n  }\n\n  const rootStats = statSync(resolved.root, { throwIfNoEntry: false })\n  if (!rootStats?.isDirectory()) {\n    throw new Error(`Root path does not exist or is not a directory: ${resolved.root}`)\n  }\n\n  resolved.mode ??= viteConfig.mode ?? 'test'\n\n  if (resolved.retry && typeof resolved.retry === 'object' && typeof resolved.retry.condition === 'function') {\n    logger.warn(\n      c.yellow('Warning: retry.condition function cannot be used inside a config file. '\n        + 'Use a RegExp pattern instead, or define the function in your test file.'),\n    )\n\n    resolved.retry = {\n      ...resolved.retry,\n      condition: undefined,\n    }\n  }\n\n  if (options.pool && typeof options.pool !== 'string') {\n    resolved.pool = options.pool.name","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/config/resolveConfig.ts#L232-L268","documentation":"During config resolution Vitest `statSync`s the resolved `root` with `throwIfNoEntry: false` and requires the result to be a directory. If the path is missing, is a file, or is any non-directory entry, it throws with the resolved path so the user can see exactly what was checked.","triggerScenarios":"Setting `root: './nonexistent'`, `root: './vitest.config.ts'` (a file, not a dir), `root: ''` (resolves to cwd that may be invalid in some sandboxes), or a relative root that resolves against an unexpected cwd. Also triggered by `--root` CLI flag pointing outside the project.","commonSituations":"Monorepo where `root` should be a package path but is set to the workspace root that lacks the expected structure; typos in config; running Vitest from a different cwd than expected; CI checkout missing a directory.","solutions":["Verify the path exists and is a directory: `ls -la <root>`.","Use an absolute path or one resolvable from cwd; print `path.resolve(process.cwd(), root)` to confirm.","If pointing at a monorepo package, set `root` to that package folder, not a config file.","Create the missing directory or fix the typo in `vitest.config.ts` / `--root`."],"exampleFix":"// before\nexport default defineConfig({ test: { root: './config' } }) // './config' is a file\n\n// after\nexport default defineConfig({ test: { root: './tests' } }) // directory exists","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nfunction assertRootValid(rawRoot: string): string {\n  const root = resolve(process.cwd(), rawRoot)\n  const stats = statSync(root, { throwIfNoEntry: false })\n  if (!stats?.isDirectory()) {\n    throw new Error(`Root is not a directory: ${root}`)\n  }\n  return root\n}\n\nexport default defineConfig({ test: { root: assertRootValid(configRoot) } })","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Print `path.resolve(cwd, root)` during config debugging to confirm what Vitest will check.","Use absolute roots in CI to avoid cwd surprises.","Point `root` at a directory, never at a config or source file."],"tags":["config","root","filesystem","resolveconfig"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}