nextjs - 💡(How to fix) Fix Typed Route Validator Fails on .tsx Routes — Hardcoded .js Reference Persists After Deletion [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#83779Fetched 2026-04-08 02:21:32
View on GitHub
Comments
1
Participants
2
Timeline
10
Reactions
0
Timeline (top)
labeled ×6closed ×1commented ×1issue_type_added ×1

Error Message

  1. Delete .next, disable typedRoutes, rename folders, create stubs — error persists
  2. Confirm that the error does not appear locally after cleanup, but reappears during Vercel deployment, even with cache disabled
  3. Validator continues to reference the deleted .js file, causing a TypeScript error: Current behavior- Build fails with a TypeScript error: I’ve already tried clearing .next, reinstalling node_modules, restarting the machine, and even renaming route folders — all from PowerShell as admin. The validator error persists regardless of environment or tooling. Despite all of this, the validator continues to auto-generate a reference to ../../app/home/page.js, even though the actual route is defined in page.tsx and no .js file exists. This causes a TypeScript error during build and blocks deployment. This issue affects emotionally sensitive legacy workflows where stability and clarity are essential. I’m reporting this without a reproduction repo because the bug is reproducible in any clean Next.js 15 setup using the App Router and .tsx routes. I’ve done everything possible to isolate and resolve it locally. I would highly appreciate your help with the reproduction repo, as I’m new to all of this and currently using Copilot to navigate the process. I find it quite long-winded to create a separate repo just for this validator error, especially since the issue is reproducible in a clean Next.js 15 setup. I can’t make my current project public, as it contains sensitive code that I don’t yet have protection for. Thank you in advance for your understanding and support. I’ve now confirmed that the error only appears during Vercel deployment. My local build is clean — no validator errors, no reference to page.js, and no duplicate route warnings. The validator error reappears on Vercel even with cache disabled and a clean Git history. This suggests that the validator is regenerating stale route references during deployment, despite the .js file being fully removed. I’ve validated this multiple times from PowerShell with a clean build and confirmed that the issue is isolated to Vercel’s build environment.

Root Cause

This issue affects emotionally sensitive legacy workflows where stability and clarity are essential. I’m reporting this without a reproduction repo because the bug is reproducible in any clean Next.js 15 setup using the App Router and .tsx routes. I’ve done everything possible to isolate and resolve it locally. I would highly appreciate your help with the reproduction repo, as I’m new to all of this and currently using Copilot to navigate the process. I find it quite long-winded to create a separate repo just for this validator error, especially since the issue is reproducible in a clean Next.js 15 setup. I can’t make my current project public, as it contains sensitive code that I don’t yet have protection for. Thank you in advance for your understanding and support.

Code Example

- Next.js version: 15.5.2
- React version: 19.1.1
- TypeScript: enabled
- App Router: enabled
- OS: Windows 11
- Node: v22.17.0
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/vercel/next.js/issues/validator-tsx-bug-placeholder

To Reproduce

  1. Create a new Next.js 15 project using the App Router and TypeScript
  2. Add a route at app/home/page.tsx — no .js file present
  3. Run npm run build
  4. Observe that .next/types/validator.ts is auto-generated with a hardcoded import to ../../app/home/page.js
  5. Delete .next, disable typedRoutes, rename folders, create stubs — error persists
  6. Confirm that the error does not appear locally after cleanup, but reappears during Vercel deployment, even with cache disabled
  7. Validator continues to reference the deleted .js file, causing a TypeScript error: "Cannot find module '../../app/home/page.js' or its corresponding type declarations"

Current vs. Expected behavior

Current behavior- Build fails with a TypeScript error:

Expected behavior- Validator should correctly resolve .tsx routes and not reference deleted .js files. Disabling typedRoutes should prevent validator generation entirely.

Provide environment information

- Next.js version: 15.5.2
- React version: 19.1.1
- TypeScript: enabled
- App Router: enabled
- OS: Windows 11
- Node: v22.17.0

Which area(s) are affected? (Select all that apply)

TypeScript, Module Resolution, Output, React, create-next-app

Which stage(s) are affected? (Select all that apply)

next build (local), Vercel (Deployed)

Additional context

The above link is a placeholder. I’m unable to provide a public reproduction repo due to sensitive code and privacy concerns, but the issue is reproducible in any clean Next.js 15 setup using App Router and .tsx routes. I’ve described all steps in detail below.

I’ve already tried clearing .next, reinstalling node_modules, restarting the machine, and even renaming route folders — all from PowerShell as admin. The validator error persists regardless of environment or tooling.

This validator bug has persisted across multiple rebuilds and troubleshooting attempts. I’ve:

  • Deleted the .next folder and rebuilt from scratch
  • Disabled typedRoutes in next.config.ts
  • Created a dummy page.js file that re-exports from page.tsx
  • Added a manual type stub to trick the validator
  • Renamed the route folder (home → home2) to force a fresh route graph
  • Uninstalled and reinstalled node_modules using PowerShell as administrator
  • Restarted the machine and cleared all caches

Despite all of this, the validator continues to auto-generate a reference to ../../app/home/page.js, even though the actual route is defined in page.tsx and no .js file exists. This causes a TypeScript error during build and blocks deployment.

This issue affects emotionally sensitive legacy workflows where stability and clarity are essential. I’m reporting this without a reproduction repo because the bug is reproducible in any clean Next.js 15 setup using the App Router and .tsx routes. I’ve done everything possible to isolate and resolve it locally. I would highly appreciate your help with the reproduction repo, as I’m new to all of this and currently using Copilot to navigate the process. I find it quite long-winded to create a separate repo just for this validator error, especially since the issue is reproducible in a clean Next.js 15 setup. I can’t make my current project public, as it contains sensitive code that I don’t yet have protection for. Thank you in advance for your understanding and support.

I’ve now confirmed that the error only appears during Vercel deployment. My local build is clean — no validator errors, no reference to page.js, and no duplicate route warnings. The validator error reappears on Vercel even with cache disabled and a clean Git history. This suggests that the validator is regenerating stale route references during deployment, despite the .js file being fully removed. I’ve validated this multiple times from PowerShell with a clean build and confirmed that the issue is isolated to Vercel’s build environment.

extent analysis

TL;DR

The most likely fix is to manually intervene in the auto-generated validator.ts file to correct the hardcoded import reference to use the .tsx file instead of the non-existent .js file.

Guidance

  • Verify that the issue is indeed caused by the auto-generated validator.ts file referencing a deleted .js file by checking the file's contents and the error message.
  • Try manually correcting the import statement in validator.ts to point to the correct .tsx file, and see if the error resolves.
  • Investigate why the typedRoutes disablement is not preventing the validator generation as expected, and consider exploring alternative configurations or workarounds.
  • Since the issue only appears during Vercel deployment, explore Vercel-specific settings or environment variables that might be influencing the behavior.

Notes

The provided information suggests that the issue is related to the auto-generated validator.ts file and its hardcoded import reference. However, without a reproduction repository, it's challenging to provide a definitive solution. The suggestions above are based on the information provided and may require further investigation and experimentation to resolve the issue.

Recommendation

Apply a workaround by manually correcting the validator.ts file or exploring alternative configurations to prevent the validator from generating a reference to the deleted .js file. This is recommended because the issue seems to be related to the auto-generated file and the typedRoutes configuration, and a workaround might be necessary until a more permanent solution is found.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING