Duplicate identifier 'PagesPageConfig' when Building a Page Router NextJS Application without an pages/api route
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/b-jv-de/next-test-pagerouter/
To Reproduce
- create a new nextjs application
npx create-next-app@latest next-test-pagerouter
Need to install the following packages:
create-next-app@16.2.9
Ok to proceed? (y) y
√ Would you like to use the recommended Next.js defaults? » No, customize settings
√ Would you like to use TypeScript? ... Yes
√ Which linter would you like to use? » ESLint
√ Would you like to use React Compiler? ... No
√ Would you like to use Tailwind CSS? ... Yes
√ Would you like your code inside a `src/` directory? ... Yes
√ Would you like to use App Router? (recommended) ... No
√ Would you like to customize the import alias (`@/*` by default)? ... No
√ Would you like to include AGENTS.md to guide coding agents to write up-to-date Next.js code? ... No
Creating a new Next.js app in C:\Projekte\bgrci\next-test.
-
start development server
npm run dev -
stop development server
-
start building
npm run build
=> no error -
delete the api folder
next-test-pagerouter\src\pages\api(or rename it to e.g. api2) -
start development server
npm run dev -
stop development server
-
start building
npm run build
=> error
npm run build
> next-test-pagerouter@0.1.0 build
> next build
✓ Running next.config.ts took 64ms
▲ Next.js 16.3.0-canary.76 (Turbopack)
Running TypeScript ...Failed to type check.
.next/dev/types/validator.ts:7:6
Type error: Duplicate identifier 'PagesPageConfig'.
5 |
6 |
> 7 | type PagesPageConfig = {
| ^
8 | default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)
9 | getStaticProps?: (context: any) => Promise<any> | any
10 | getStaticPaths?: (context: any) => Promise<any> | any
Next.js build worker exited with code: 1 and signal: null
- delete the
.nextfolder - start building
npm run build
=> no error
Current vs. Expected behavior
I expected no error on typescript validation.
The error occurs when there is no api route on build when the development mode was started before.
When the api route exists you can run dev/build without an issue.
When you delete the .next folder before building the error also doesn't happen.
Provide environment information
perating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 15151
Available CPU cores: 12
Binaries:
Node: 24.5.0
npm: 11.5.1
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 16.3.0-canary.81 // Latest available version is detected (16.3.0-canary.81).
eslint-config-next: N/A
react: 19.2.4
react-dom: 19.2.4
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked next-test-pagerouter reproduction and follow the dev-then-build sequence after removing src/pages/api. Inspect the generated .next/dev/types/validator.ts where PagesPageConfig is duplicated. Done means next build passes without deleting .next, both with and without the pages/api route.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100