T
TanStack2mo ago
sunny-green

Tanstack/router: Unable to generate route tree file

Does anyone have an idea about https://github.com/TanStack/router/issues/4912 please ?
GitHub
Unable to generate route tree file (routeTree.gen.ts) during build ...
Which project does this relate to? Router Describe the bug When building a project using TanStack Router with route generation enabled, the build fails with an ENOENT error because the router gener...
4 Replies
national-gold
national-gold2mo ago
we need a reproducible setup somehow
sunny-green
sunny-greenOP2mo ago
He ! By reproducing the error, I found the cause. The problem happens because TanStack Router cannot generate the route tree file inside a subfolder that hasn’t been created yet. Since Git doesn’t keep empty folders, the subfolder is missing in CI and the generation fails. The error message isn’t very clear, but the fix is: 👉 Add a .gitkeep file to keep those subfolders in Git. Example:
src/generated/.gitkeep
src/generated/.gitkeep
This way the generated routeTree.gen.ts file has a valid parent folder, and CI won’t fail. 🚀
national-gold
national-gold2mo ago
that should be fixable in the generator ensuring the folder exists want to create a PR for this?
national-gold
national-gold2mo ago
I've added a check for this to the generator on the Alpha branch. This will be available when Alpha is merged to main.

Did you find this page helpful?