Repository navigation
Labels
Description
Environment
Both nitro v3 and v2.
Node v24.12.0
Reproduction
Here's the reproducible:
https://github.com/josippapez/tanstack-vercel-reproducible
Describe the bug
I get the following error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/my-app/.output/server/server.js' imported from /my-app/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_rea_8f07dd2dc4f2e030cbea330a30ef30f3/node_modules/@tanstack/start-plugin-core/dist/esm/preview-server-plugin/plugin.js
at finalizeResolution (node:internal/modules/esm/resolve:274:11)
at moduleResolve (node:internal/modules/esm/resolve:864:10)
at defaultResolve (node:internal/modules/esm/resolve:990:11)
at nextResolve (node:internal/modules/esm/hooks:785:28)
at o (file:///my-app/node_modules/.pnpm/@[email protected]/node_modules/@tailwindcss/node/dist/esm-cache.loader.mjs:1:69)
at nextResolve (node:internal/modules/esm/hooks:785:28)
at AsyncLoaderHooksOnLoaderHookWorker.resolve (node:internal/modules/esm/hooks:271:30)
at MessagePort.handleMessage (node:internal/modules/esm/worker:251:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:845:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
For this vite.config.ts
import { defineConfig } from 'vite';
import { tanstackStart } from '@tanstack/react-start/plugin/vite';
import viteReact from '@vitejs/plugin-react';
import viteTsConfigPaths from 'vite-tsconfig-paths';
import tailwindcss from '@tailwindcss/vite';
import { nitro } from 'nitro/vite';
const config = defineConfig({
build: {
sourcemap: true,
outDir: '.output',
emptyOutDir: true,
target: 'es2022',
minify: true,
rollupOptions: {
treeshake: true,
output: {
manualChunks: (id: string) => {
if (
id.includes('phone/dist') ||
id.includes('react-phone-number-input')
) {
return 'phone';
}
if (id.includes('lodash')) {
return 'lodash';
}
if (id.includes('country-flag-icons')) {
return 'country-flag-icons';
}
if (id.includes('medusa')) {
return 'medusa';
}
},
},
},
},
plugins: [
// this is the plugin that enables path aliases
viteTsConfigPaths({
projects: ['./tsconfig.json'],
}),
tailwindcss(),
tanstackStart(),
nitro({
preset: 'vercel',
output: {
dir: '.output',
serverDir: '.output/server',
publicDir: '.output/static',
},
routeRules: {
// Cache fonts for 1 year (immutable)
'/fonts/**': {
headers: {
'Cache-Control': 'public, max-age=31536000, immutable',
},
},
// Cache images for 1 month
'/**/*.{jpg,jpeg,png,gif,webp,svg,ico}': {
headers: {
'Cache-Control': 'public, max-age=2592000',
},
},
// cache css
'/**/*.{css}': {
headers: {
'Cache-Control': 'public, max-age=604800',
},
},
},
}),
viteReact(),
],
resolve: {
alias: {
'/fonts': '/public/fonts',
},
},
ssr: {
noExternal: ['@radix-ui/*', '@medusajs/*', 'nuqs'],
},
});
export default config;
I did try invoking server.js/index.mjs directly with pnpm serve and node .output/server/index.mjs.
and then i try to pnpm dev (works), pnpm build passes and then pnpm preview and node index.mjs directly, and the node one doesn't start while the preview returns the same error as above
Additional context
No response
Logs
Reacted by Fuma Nama and Ethan Shumate
Activity
pi0 commentedon Dec 30, 2025
Have you tried removing
outputconfig? setting it manually can break deployment.(PS: There is no supported nitro v2 vite plugin (for tanstack start) only nitro v3.)
agustinusnathaniel commentedon Jan 2, 2026
Also reproduced on my side
Deploying tanstack start app to vercel with prerendering on latest tanstack start and latest nitro-nightly
Using nitro v3
Here's my package.json:
{ ..., "dependencies": { ..., "@tanstack/react-router": "1.144.0", "@tanstack/react-start": "1.145.3", ... }, "devDependencies": { ..., "nitro": "npm:[email protected]", ... } }Here's my vite.config.ts:
Then during build there's this error:
josippapez commentedon Jan 5, 2026
Sorry, the missing notifications feature on github is killing me...
Yes, i did, i did try with:
and it didn't fix anything, also, even without routeRules it's still the same (only gaving preset in the nitro)
pi0 commentedon Jan 5, 2026
Please provide a minimal reproduction. (also try latest tss and nitro nightly, tss prerender started to break at somepoint)
EthanShoeDev commentedon Jan 5, 2026
Was also hitting this bug. I got opus 4.5 to use
bun patchand it eventually worked with this.[email protected]
FYI - Not expecting this to be upstreamed. Just wanted to add it as reference.
pi0 commentedon Jan 5, 2026
Thanks for ref @EthanShoeDev. #3921 should fix preview command (therefore tss prerendering support) for vercel.
agustinusnathaniel commentedon Jan 6, 2026
Still error during build on vercel with the latest nightly
Unless I explicitly install
srvxto package.json dependencies or devDependencies and then its successful or able to run.Is this expected?
[-]Vercel preset on both v2 and v3 nitro not working in Tanstack Start[/-][+] Tanstack Start prerender broken with Nitro v3[/+][-] Tanstack Start prerender broken with Nitro v3[/-][+] Tanstack Start prerender broken with Nitro v3 on Vercel[/+]2 remaining items
josippapez commentedon Jan 7, 2026
@pi0 For me, after bumping to the latest nightly, it started to work... At least, i was able to run the vite preview now and it would start a local production build and i was able to deploy it to vercel. I will probably encounter some problems but it's a start
Zefty commentedon Jan 7, 2026
Hi team, i've run into similar issues. Using latest nightly version of nitro and TSS but getting this error with pg even though I have the dependency installed
EIDT: my config
fuma-nama commentedon Jan 29, 2026
I suspect there is changes to the behaviour of
srvxor nitro, the way Nitro closes the preview server will cause the build process to end with code 143 (which is a fail signal).Tried on
npm:[email protected], and3.0.1-alpha.2.It is pretty minimal:
pi0 commentedon Jan 29, 2026
might be relavant to #3907 (/cc @schiller-manuel) @fuma-nama please consider a runnable reproduiction it makes it easier for us to investigate 🙏🏼
fuma-nama commentedon Jan 29, 2026
Yep it is currently in my monorepo, will look into it and make a separate reproduction tomorrow.
fuma-nama commentedon Jan 30, 2026
made the reproduction, you can run the build command to reproduce:
https://github.com/fuma-nama/tanstack-start-reproduction
fix(nitro): upgrade to 3.0.260311-beta — fix Vercel 508 infinite loop
fix: restore SPA prerendering with nitro@3 workaround
fix: disable prerendering for docs to fix Vercel build
GitHub Pages Deployment via GitHub Actions einrichten
Add Nitro so the Vercel deploy actually serves
fix: force single-file SSR bundle to avoid Nitro/Vercel circular-impo…