Skip to content

nitro + spa mode breaks since v1.138.0 #5967

@ImSingee

Description

@ImSingee

Which project does this relate to?

Start

Describe the bug

If you use nitro + spa mode, the vite build will report this error:

✓ built in 535ms
[prerender] Prerendering pages...
error during build:
Error: Failed to start the Vite preview server for prerendering
    at startPreviewServer (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:195:11)
    at async prerender (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:42:25)
    at async postServerBuild (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:38:5)
    at async BasicMinimalPluginContext.handler (file:///project-dir/node_modules/.pnpm/@tanstack+start-plugin-core@1.139.6_@tanstack+react-router@1.139.6_react-dom@19.2.0_rea_4811f95400dc016e184359a72f378162/node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:267:11)
    at async Object.buildApp (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@24.10.1_jiti@2.6.1_lightningcss@1.30.2_sugarss@5.0.1_postcss@8.5.6__tsx@4.20.6_yaml@2.8.1/node_modules/vite/dist/node/chunks/config.js:34542:5)
    at async CAC.<anonymous> (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@24.10.1_jiti@2.6.1_lightningcss@1.30.2_sugarss@5.0.1_postcss@8.5.6__tsx@4.20.6_yaml@2.8.1/node_modules/vite/dist/node/cli.js:629:3)                                                                                                                                                                  
 ELIFECYCLE  Command failed with exit code 1.

Your Example Website or App

https://github.com/ImSingee/tanstack-start-bug-reproduce-for-spa

Steps to Reproduce the Bug or Issue

  1. Setup nitro with tanstack start (https://tanstack.com/start/latest/docs/framework/react/guide/hosting#nitro)
  2. Enable SPA mode (https://tanstack.com/start/latest/docs/framework/react/guide/spa-mode)

Expected behavior

Build should be success

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.139.6
  • OS: macOS
  • Bundler: vite
  • Bundler Version: ^7.2.4

Additional context

I created a bug-reproduce repo with the latest version, but I can confirm the issue starts at v1.138.0 after #5921 is merged.

After executing the pnpm build (failed), then execute npx vite preview, this error occurs:

error when starting preview server:
Error: Cannot load nitro build info. Make sure to build first.
    at BasicMinimalPluginContext.error (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@22.19.1_jiti@2.6.1_lightningcss@1.30.2_tsx@4.20.6/node_modules/vite/dist/node/chunks/config.js:29511:35)
    at BasicMinimalPluginContext.configurePreviewServer (file:///project-dir/node_modules/.pnpm/nitro@3.0.1-alpha.1_rollup@4.53.3_vite@7.2.4_@types+node@22.19.1_jiti@2.6.1_lightningcss@1.30.2_tsx@4.20.6_/node_modules/nitro/dist/_build/vite.plugin.mjs:443:31)
    at async preview (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@22.19.1_jiti@2.6.1_lightningcss@1.30.2_tsx@4.20.6/node_modules/vite/dist/node/chunks/config.js:35765:93)
    at async CAC.<anonymous> (file:///project-dir/node_modules/.pnpm/vite@7.2.4_@types+node@22.19.1_jiti@2.6.1_lightningcss@1.30.2_tsx@4.20.6/node_modules/vite/dist/node/cli.js:669:18)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions