Tanstack/router: Unable to generate route tree file
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•2mo ago
we need a reproducible setup somehow
sunny-greenOP•2mo 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:
This way the generated routeTree.gen.ts
file has a valid parent folder, and CI won’t fail. 🚀national-gold•2mo ago
that should be fixable in the generator
ensuring the folder exists
want to create a PR for this?
national-gold•2mo 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.