{"record":{"id":"b3534a91e7c780a5","repo":"vercel/next.js","slug":"couldn-t-find-any-pages-or-app-directory-pl","errorCode":null,"errorMessage":"> Couldn't find any `pages` or `app` directory. Please create one under the project root","messagePattern":"> Couldn't find any `pages` or `app` directory\\. Please create one under the project root","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/find-pages-dir.ts","lineNumber":23,"sourceCode":"  // prioritize ./${name} over ./src/${name}\n  let curDir = path.join(dir, name)\n  if (fs.existsSync(curDir)) return curDir\n\n  curDir = path.join(dir, 'src', name)\n  if (fs.existsSync(curDir)) return curDir\n\n  return null\n}\n\nexport function findPagesDir(dir: string): {\n  pagesDir: string | undefined\n  appDir: string | undefined\n} {\n  const pagesDir = findDir(dir, 'pages') || undefined\n  const appDir = findDir(dir, 'app') || undefined\n\n  if (appDir == null && pagesDir == null) {\n    throw new Error(\n      \"> Couldn't find any `pages` or `app` directory. Please create one under the project root\"\n    )\n  }\n\n  if (pagesDir && appDir) {\n    const pagesParent = path.dirname(pagesDir)\n    const appParent = path.dirname(appDir)\n    if (pagesParent !== appParent) {\n      throw new Error(\n        '> `pages` and `app` directories should be under the same folder'\n      )\n    }\n  }\n\n  return {\n    pagesDir,\n    appDir,\n  }","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/vercel/next.js/blob/0eb377541648e63402a47b38fee00a8d0ce8f8f1/packages/next/src/lib/find-pages-dir.ts#L5-L41","documentation":"Project layout validation in findPagesDir: neither a pages/ nor an app/ directory was found at the project root or under src/. Next.js has no routes to serve, so startup fails with this error rather than serving an empty application.","triggerScenarios":"Next.js cannot find a pages or app directory at startup.","commonSituations":"Running next dev/build in a project missing both pages/ and app/ directories or with wrong root.","solutions":["Create a pages/ or app/ directory at the project root (or under src/)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0eb377541648e63402a47b38fee00a8d0ce8f8f1","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}