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
- Create a Next.js 16.0.1 project with App Router
- Create a
pages directory at the project root with only a README.md file inside
- 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.
Description
In Next.js 16.0.1, having an empty
pagesdirectory (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
pagesdirectory at the project root with only aREADME.mdfile insidenext buildCurrent 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
pagesdirectory 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
pagesfolder at the project root is required to prevent Next.js from treatingsrc/pagesas the Pages Router directory.The FSD documentation states:
This approach worked in Next.js 14 and 15 but breaks in Next.js 16.
Environment
Additional Information
This error was resolved by downgrading to Next.js 15.