vercel/next.js · error · Error

> `pages` and `app` directories should be under the same…

Error message

> `pages` and `app` directories should be under the same folder

What it means

Layout consistency check in findPagesDir: both pages/ and app/ were found but their parent directories differ (e.g. one under src/ and one at the root). The router cannot disambiguate route precedence between split directories, so the mixed layout is rejected at startup.

Solutions

  1. Move pages/ and app/ so both live at the project root or both under src/.
Defensive patterns

Strategy: validation

When it happens

Trigger: pages and app directories are found in different parent folders.

Common situations: A project mixes src/app with top-level pages/ instead of colocating them under the same folder.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/98a32fa4ed53ad86. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/lib/find-pages-dir.ts:32

export function findPagesDir(dir: string): {
  pagesDir: string | undefined
  appDir: string | undefined
} {
  const pagesDir = findDir(dir, 'pages') || undefined
  const appDir = findDir(dir, 'app') || undefined

  if (appDir == null && pagesDir == null) {
    throw new Error(
      "> Couldn't find any `pages` or `app` directory. Please create one under the project root"
    )
  }

  if (pagesDir && appDir) {
    const pagesParent = path.dirname(pagesDir)
    const appParent = path.dirname(appDir)
    if (pagesParent !== appParent) {
      throw new Error(
        '> `pages` and `app` directories should be under the same folder'
      )
    }
  }

  return {
    pagesDir,
    appDir,
  }
}

View on GitHub (pinned to 0eb3775416)