{"record":{"id":"b49d365d2ced3578","repo":"withastro/astro","slug":"missing-pages-directory-pagesdirrootrelative","errorCode":null,"errorMessage":"Missing pages directory: ${pagesDirRootRelative}","messagePattern":"Missing pages directory: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/core/routing/create-manifest.ts","lineNumber":134,"sourceCode":"\tcwd?: string;\n\t/** fs module, for testing */\n\tfsMod?: typeof nodeFs;\n}\n\nfunction createFileBasedRoutes(\n\t{ settings, cwd, fsMod }: CreateRouteManifestParams,\n\tlogger: AstroLogger,\n): RouteData[] {\n\tconst { config } = settings;\n\tconst pages = resolvePages(config);\n\tconst localFs = fsMod ?? nodeFs;\n\tconst rootPath = fileURLToPath(config.root);\n\tconst pagesPath = fileURLToPath(pages);\n\n\tif (!localFs.existsSync(pages)) {\n\t\tif (settings.injectedRoutes.length === 0) {\n\t\t\tconst pagesDirRootRelative = pages.href.slice(settings.config.root.href.length);\n\t\t\tlogger.warn(null, `Missing pages directory: ${pagesDirRootRelative}`);\n\t\t}\n\t\treturn [];\n\t}\n\n\tconst routes: RouteData[] = [];\n\tconst validPageExtensions = new Set<string>([\n\t\t'.astro',\n\t\t...SUPPORTED_MARKDOWN_FILE_EXTENSIONS,\n\t\t...settings.pageExtensions,\n\t]);\n\tconst invalidPotentialPages = new Set<string>(['.tsx', '.jsx', '.vue', '.svelte']);\n\tconst validEndpointExtensions = new Set<string>(['.js', '.ts']);\n\tconst prerender = getPrerenderDefault(settings.config);\n\n\tfunction walk(\n\t\tfs: typeof nodeFs,\n\t\tdir: string,\n\t\tparentSegments: RoutePart[][],","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/core/routing/create-manifest.ts#L116-L152","documentation":"When building the route manifest, Astro resolves the pages directory (src/pages by default). If it does not exist on disk and no integration injected routes, Astro logs this warning and returns an empty route list — you get a page-less build/dev session instead of a hard failure.","triggerScenarios":"Running astro dev/build/sync when src/pages (or the pages dir derived from srcDir) does not exist and settings.injectedRoutes is empty.","commonSituations":"Fresh project scaffolded without pages; src/pages renamed or srcDir changed without moving files; projects expecting an adapter/integration to inject all routes while the integration fails to run.","solutions":["Create the missing directory (mkdir -p src/pages) and add at least one page","If pages live elsewhere, correct srcDir (or the integration-provided pages config) so Astro scans the right folder","If all routes come from integrations, verify the integration's injectRoute calls actually execute in astro:config:setup"],"exampleFix":"# before\nsrc/\n  components/\n  layouts/\n# (no pages directory — warning on every command)\n\n# after\nmkdir -p src/pages\necho '<html><body>Hello</body></html>' > src/pages/index.astro","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nif (!existsSync(resolve('src/pages'))) {\n  console.error('src/pages is missing — create it or fix srcDir');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep at least one page in src/pages from project inception","When moving pages, update srcDir in the same commit","If all routes are injected, verify the integration loads before the first build"],"tags":["routing","pages-directory","filesystem","project-structure"],"backgroundTag":"missing-pages-directory","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}