T
TanStack12mo ago
rival-black

Importing generated router file causes nitro startup error

Hi! I am using tanstack router with vinxi and trying to get ssr working (before you ask I have reasons for not using start although it is very cool) When I start the nitro server (via vinxi start after building, dev server works fine) I run into this very cryptic error on startup not on request:
ERROR Cannot read properties of undefined (reading 'client') 11:51:55 PM

at x (.output/server/chunks/runtime.mjs:5942:29)
at .output/server/chunks/runtime.mjs:5959:13
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
at async Object.run (node_modules/.pnpm/vinxi@0.4.3_@libsql+client@0.12.0_@types+node@22.6.1_drizzle-orm@0.33.0_@libsql+client@0.12.0_yxjwf4rzu6x3of72h5i7bk6an4/node_modules/vinxi/bin/cli.mjs:278:7)
at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:316:16)
at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:307:11)
at async runMain (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:445:7)



ERROR Cannot read properties of undefined (reading 'client')
ERROR Cannot read properties of undefined (reading 'client') 11:51:55 PM

at x (.output/server/chunks/runtime.mjs:5942:29)
at .output/server/chunks/runtime.mjs:5959:13
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
at async Object.run (node_modules/.pnpm/vinxi@0.4.3_@libsql+client@0.12.0_@types+node@22.6.1_drizzle-orm@0.33.0_@libsql+client@0.12.0_yxjwf4rzu6x3of72h5i7bk6an4/node_modules/vinxi/bin/cli.mjs:278:7)
at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:316:16)
at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:307:11)
at async runMain (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:445:7)



ERROR Cannot read properties of undefined (reading 'client')
I have narrowed it down to the import of my generated file-based router file: https://github.com/ethanniser/sase-template/blob/ssr/client/router.tsx#L9 If I comment this line, the server manages to start (although obviously breaks due to the unresolved variable) The thing is, this import used in this way is taken directly from the docs: https://tanstack.com/router/latest/docs/framework/react/guide/ssr#router-creation So I am not really sure what to do... Any help is greatly appreciated thank you
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
GitHub
sase-template/client/router.tsx at ssr · ethanniser/sase-template
Contribute to ethanniser/sase-template development by creating an account on GitHub.
2 Replies
correct-apricot
correct-apricot12mo ago
Probably this line? const clientManifest = getManifest("client"); Looking at this example: https://www.brenelz.com/posts/simple-rsc-with-vinxi/ There is a plugin import { serverComponents } from "@vinxi/server-components/plugin"; Might be something to do with it? I'm just guessing though
like-gold
like-gold12mo ago
The TanStack Start SSR config is pretty in-depth for vinxi. You may want to look at our config on github. packages/start/src/config/index.ts

Did you find this page helpful?