T
TanStack8mo ago
automatic-azure

[vite] Internal server error: [...]routeTree.gen.ts:28:1: ERROR: Expected identifier but found "/"

I am setting up a new vite-react project and intend to use tanstack-router. I have followed the Quick start instructions, but end up getting the following error when I run the development server. I have copied and named the files and directories as per the docs; __root.tsx, about.lazy.tsx, index.lazy.tsx, main.tsx.
8:53:16 AM [vite] (client) Pre-transform error: Transform failed with 1 error:
/home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1: ERROR: Expected identifier but found "/"
Plugin: vite:esbuild
File: /home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1

Expected identifier but found "/"
26 | getParentRoute: () => rootRoute,
27 | } as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
28 | ./routes/index.lazy
| ^
29 | // Populate the FileRoutesByPath interface
30 |

8:53:16 AM [vite] Internal server error: Transform failed with 1 error:
/home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1: ERROR: Expected identifier but found "/"
Plugin: vite:esbuild
File: /home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1

Expected identifier but found "/"
26 | getParentRoute: () => rootRoute,
27 | } as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
28 | ./routes/index.lazy
| ^
29 | // Populate the FileRoutesByPath interface
30 |
8:53:16 AM [vite] (client) Pre-transform error: Transform failed with 1 error:
/home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1: ERROR: Expected identifier but found "/"
Plugin: vite:esbuild
File: /home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1

Expected identifier but found "/"
26 | getParentRoute: () => rootRoute,
27 | } as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
28 | ./routes/index.lazy
| ^
29 | // Populate the FileRoutesByPath interface
30 |

8:53:16 AM [vite] Internal server error: Transform failed with 1 error:
/home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1: ERROR: Expected identifier but found "/"
Plugin: vite:esbuild
File: /home/<user>/dev/tmp-front-end/analytics-portal-poc/src/routeTree.gen.ts:28:1

Expected identifier but found "/"
26 | getParentRoute: () => rootRoute,
27 | } as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
28 | ./routes/index.lazy
| ^
29 | // Populate the FileRoutesByPath interface
30 |
1 Reply
automatic-azure
automatic-azureOP8mo ago
Seems like the generated file routeTree.gen.ts was outdated. I deleted it, and re-ran the dev server. The file was re-generated, and everything works now.

Did you find this page helpful?