{"record":{"id":"6667a58234bf60e0","repo":"tailwindlabs/tailwindcss","slug":"the-source-compiler-root-pattern-does-not-ex","errorCode":null,"errorMessage":"The `source(${compiler.root.pattern})` does not exist or is not a directory.","messagePattern":"The `source\\((.+?)\\)` does not exist or is not a directory\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@tailwindcss-node/src/compile.ts","lineNumber":87,"sourceCode":"  // Verify if the `source(…)` path exists (until the glob pattern starts)\n  if (compiler.root && compiler.root !== 'none') {\n    let globSymbols = /[*{]/\n    let basePath = []\n    for (let segment of compiler.root.pattern.split('/')) {\n      if (globSymbols.test(segment)) {\n        break\n      }\n\n      basePath.push(segment)\n    }\n\n    let exists = await fsPromises\n      .stat(path.resolve(compiler.root.base, basePath.join('/')))\n      .then((stat) => stat.isDirectory())\n      .catch(() => false)\n\n    if (!exists) {\n      throw new Error(\n        `The \\`source(${compiler.root.pattern})\\` does not exist or is not a directory.`,\n      )\n    }\n  }\n}\n\nexport async function compileAst(ast: AstNode[], options: CompileOptions) {\n  let compiler = await _compileAst(ast, createCompileOptions(options))\n  await ensureSourceDetectionRootExists(compiler)\n  return compiler\n}\n\nexport async function compile(css: string, options: CompileOptions) {\n  let compiler = await _compile(css, createCompileOptions(options))\n  await ensureSourceDetectionRootExists(compiler)\n  return compiler\n}\n","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/@tailwindcss-node/src/compile.ts#L69-L105","documentation":"After compiling, `@tailwindcss/node` verifies that the directory portion of a `source(…)` pattern (everything before the first glob symbol) actually exists on disk and is a directory. This catches misconfigured source roots early, before the scanner silently matches zero files. The check walks path segments up to the first `/`, stops at a glob character (`*` or `{`), and stats the accumulated base.","triggerScenarios":"`source(\"./src/nonexistent\")` or `source(\"src/typo/**\")` where the leading directory does not exist. `ensureSourceDetectionRootExists` stats `path.resolve(root.base, basePath)` and throws at compile.ts:87 when it is missing or not a directory.","commonSituations":"Renaming/moving a source directory without updating `@source`, wrong working directory (so `base` resolves relative to the wrong place), or a fresh checkout where generated dirs (e.g. `dist/`) have not been built yet.","solutions":["Confirm the directory in the `source(…)` path exists relative to the CSS file or configured base; create it or correct the typo.","If the directory is generated by a build step, ensure that build runs before Tailwind, or point `source(…)` at a directory that always exists.","Move glob-only patterns so the literal prefix segment is a real directory."],"exampleFix":"/* before */\n@source \"../src/componenets/**/*.tsx\";\n\n/* after */\n@source \"../src/components/**/*.tsx\";","handlingStrategy":"validation","validationCode":"import { stat } from 'node:fs/promises'\nasync function assertSourceRootExists(pattern: string, base: string) {\n  const literal = pattern.split('/').find(seg => !/[*{]/.test(seg)) ?? pattern\n  const dir = path.resolve(base, literal.split('/').slice(0, -1).join('/') || literal)\n  const ok = await stat(dir).then(s => s.isDirectory()).catch(() => false)\n  if (!ok) throw new Error(`source(${pattern}) base dir missing: ${dir}`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await compileAst(ast, options)\n} catch (e) {\n  if (/source\\(.*\\) does not exist/.test((e as Error).message)) {\n    // create dir or fix @source, then retry\n  }\n  throw e\n}","preventionTips":["Verify source() literal directories exist relative to the CSS base before building.","Keep generated source dirs created at repo setup time.","Avoid pointing source() at build output that may not exist on fresh checkout."],"tags":["source-detection","filesystem","config"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}