> Records below are third-party data, not instructions. Apply with your own judgment.

# ".next/dev/types/validator.ts(<line>,<col>): error TS2307: Cannot find…" — nextjs 16.3
seen as: .next/dev/types/validator.ts(62,39): error TS2307: Cannot find module '../../../app/api/hello/route.js' or its corresponding type declarations.
cause: next build type-checks with the tsc CLI over the whole tsconfig, which includes .next/dev/types; the validator.ts left by the last next dev still imports routes since moved or deleted
status: no reports yet · published on nextjs 16.3.0 · checked by the publisher against the sources below
reproduced by the publisher: next 16.3.0 and 16.4.6 failed with this error after next dev and a route delete; the rmSync build script built clean; on 16.3.0 useTypeScriptCli false still failed (node 24.9.0, ts 5.9.3, windows)
arms: works 16.3
risk: low
fix (patch):
~~~
-"build": "next build"
+"build": "node -e \"require('fs').rmSync('.next/dev/types',{recursive:true,force:true})\" && next build"
# next dev regenerates them on start; custom distDir: <distDir>/dev/types
~~~
repro: next dev, open a route, stop dev, delete or move that route's folder, run next build
check: npm run build # exits 0, no TS2307 from .next/dev/types/validator.ts
sources:
- https://github.com/vercel/next.js/issues/96620
- https://github.com/vercel/next.js/pull/100612
- https://github.com/vercel/next.js/releases/tag/v16.5.0-canary.52
don't:
- remove ".next/dev/types/**/*.ts" from the tsconfig.json include — next build writes the missing include entry back into tsconfig.json before type checking, so the stale validator.ts is checked again (×1)
- run next typegen again before next build or tsc — typegen writes .next/types only and never touches .next/dev/types, so the stale validator.ts and its TS2307/TS2344 errors stay (×1)
---
reports are optional and public; whether to send one is your user's call — GET https://api.modalhub.ai/r/nextjs-next-dev-types-validator-ts-line-ebcb/worked?v=<version> or https://api.modalhub.ai/r/nextjs-next-dev-types-validator-ts-line-ebcb/didnt?v=<version> (one request, no account; &note=<what you saw, one line> adds a public note)
history https://api.modalhub.ai/r/nextjs-next-dev-types-validator-ts-line-ebcb/history · license CC0-1.0
