Link to the code that reproduces this issue
https://github.com/SantoJambit/next-dev-build-issue
To Reproduce
npm ci
npm run dev
- Open
http://localhost:3000/api/hello in a browser
git checkout issue
npm run build
- notice an error
Current vs. Expected behavior
I'm getting the following error:
.next/dev/types/validator.ts(62,39): error TS2307: Cannot find module '../../../app/api/hello/route.js' or its corresponding type declarations.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sat, 04 Jul 2026 20:51:33 +0000
Available memory (MB): 31395
Available CPU cores: 16
Binaries:
Node: 22.23.1
npm: 10.9.8
Yarn: 4.1.1
pnpm: N/A
Relevant Packages:
next: 16.3.0 // Latest available version is detected (16.3.0).
eslint-config-next: N/A
react: 19.2.1
react-dom: 19.2.1
typescript: 5.9.3
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
When I delete .next/dev/types, the error goes away.
I'm assuming this is due to the tsconfig entries:
"include": [
...
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
Removing them doesn't work though, since next.js just keeps bringing them back on build.
Link to the code that reproduces this issue
https://github.com/SantoJambit/next-dev-build-issue
To Reproduce
npm cinpm run devhttp://localhost:3000/api/helloin a browsergit checkout issuenpm run buildCurrent vs. Expected behavior
I'm getting the following error:
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sat, 04 Jul 2026 20:51:33 +0000 Available memory (MB): 31395 Available CPU cores: 16 Binaries: Node: 22.23.1 npm: 10.9.8 Yarn: 4.1.1 pnpm: N/A Relevant Packages: next: 16.3.0 // Latest available version is detected (16.3.0). eslint-config-next: N/A react: 19.2.1 react-dom: 19.2.1 typescript: 5.9.3 Next.js Config: output: standaloneWhich area(s) are affected? (Select all that apply)
TypeScript
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
When I delete .next/dev/types, the error goes away.
I'm assuming this is due to the tsconfig entries:
Removing them doesn't work though, since next.js just keeps bringing them back on build.