Skip to content

Empty pages directory causes build failure in Next.js 16 with App Router #874

@dkmqflx

Description

@dkmqflx

Description

In Next.js 16.0.1, having an empty pages directory (containing only a README.md file) causes build failures when using the App Router. This worked correctly in Next.js 14 and 15.

To Reproduce

  1. Create a Next.js 16.0.1 project with App Router
  2. Create a pages directory at the project root with only a README.md file inside
  3. Run next build

Current vs. Expected behavior

Current behavior:
Build fails with error:
Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error Error [PageNotFoundError]: Cannot find module for page: /_document at ignore-listed frames { code: 'ENOENT' }

Expected behavior:
Build should succeed. Next.js should ignore the empty pages directory when using App Router, as it did in versions 14 and 15.

Context

This issue affects projects using Feature-Sliced Design (FSD) architecture. According to FSD documentation, an empty pages folder at the project root is required to prevent Next.js from treating src/pages as the Pages Router directory.

The FSD documentation states:

"You will also need to add a pages folder to the project root, otherwise Next.js will try to use src/pages as the Pages Router even if you use the App Router, which will break the build."

This approach worked in Next.js 14 and 15 but breaks in Next.js 16.

Environment

  • Next.js version: 16.0.1
  • Node.js version: 20.9+
  • Operating System: macOS (also reproducible on other platforms)
  • Package Manager: pnpm

Additional Information

This error was resolved by downgrading to Next.js 15.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions