Tanstack start works locally but not deployed on railway
kevmok
PROOP

10 months ago

Hi there

Has anyone been able to deploy tanstack start with react 19.0.0 (which is the recommended version with bun)? It looks like it does not work I get the error:
[start]: preset:bun - Cannot find module "react-dom/server" from "/.output/server/index.mjs

I’m using railpack as well.

No issues on my local machine (of course 😭) but not sure why it’s not working when the app deploys in my project

Solved

22 Replies

kevmok
PROOP

10 months ago

f5376e47-25bc-4744-8e51-94719df911c0


alex-delia
PRO

10 months ago

https://railway.com/template/nAdb0P?referralCode=EmK2DS

i have a template here that deploys tanstack start


kevmok
PROOP

10 months ago

I see, I think my issue might be around using bun


alex-delia
PRO

10 months ago

is railpack recognizing bun in your settings

1360725588045860900


kevmok
PROOP

10 months ago

Yeah


kevmok
PROOP

10 months ago

1360748338252878000


kevmok
PROOP

10 months ago

In my local running bun --filter agora start which uses vinxi start works, but if i manually do bun .output/server/index.mjs i get the same error railway is surfacing


kevmok
PROOP

10 months ago

not sure if railway is not runing vinxi start


alex-delia
PRO

10 months ago

can you share your package.json?


kevmok
PROOP

10 months ago

{
    "name": "agora",
    "private": true,
    "type": "module",
    "scripts": {
        "start": "vinxi start",
        "build": "bun vinxi build --preset node-server",
        "local-build": "bun with-env vinxi build",
        "serve": "vite preview",
        "test": "vitest run",
        "dev": "bun with-env vinxi dev",
        "with-env": "bun --env-file=../../.env --bun",
        "ui:add": "bunx --bun shadcn@latest add"
    },
    "dependencies": {
        "@better-auth/stripe": "^1.2.5",
        "@daveyplate/better-auth-tanstack": "^1.3.2",
        "@daveyplate/better-auth-ui": "^1.3.21",
        "@efnf/eden": "workspace:*",
        "@efnf/types": "workspace:*",
        "@polar-sh/sdk": "^0.30.0",
        "@radix-ui/react-aspect-ratio": "^1.1.2",
        "@radix-ui/react-avatar": "^1.1.3",
        "@radix-ui/react-collapsible": "^1.1.3",
        "@radix-ui/react-dialog": "^1.1.6",
        "@radix-ui/react-dropdown-menu": "^2.1.6",
        "@radix-ui/react-label": "^2.1.2",
        "@radix-ui/react-radio-group": "^1.2.3",
        "@radix-ui/react-select": "^2.1.6",
        "@radix-ui/react-separator": "^1.1.2",
        "@radix-ui/react-slot": "^1.1.2",
        "@radix-ui/react-switch": "^1.1.3",
        "@radix-ui/react-tooltip": "^1.1.8",
        "@t3-oss/env-core": "^0.12.0",
        "@tailwindcss/postcss": "^4.0.7",
        "@tailwindcss/vite": "^4.0.6",
        "@tanstack/react-form": "^1.0.0",
        "@tanstack/react-query": "^5.66.11",
        "@tanstack/react-query-devtools": "^5.66.11",
        "@tanstack/react-router": "^1.104.1",
        "@tanstack/react-router-devtools": "^1.114.34",
        "@tanstack/react-router-with-query": "^1.112.0",
        "@tanstack/react-start": "^1.111.12",
        "@tanstack/react-store": "^0.7.0",
        "@tanstack/router-devtools": "^1.104.3",
        "@tanstack/router-plugin": "^1.105.0",
        "better-auth": "^1.2.5",
        "class-variance-authority": "^0.7.1",
        "clsx": "^2.1.1",
        "date-fns": "^4.1.0",
        "embla-carousel-react": "^8.5.2",
        "lucide-react": "^0.477.0",
        "mercury": "workspace:*",
        "next-themes": "^0.4.4",
        "postcss": "^8.5.2",
        "react": "^19.0.0",
        "react-dom": "^19.0.0",
        "sonner": "^2.0.1",
        "tailwind-merge": "^3.0.2",
        "tailwindcss": "^4.0.6",
        "tailwindcss-animate": "^1.0.7",
        "vinxi": "^0.5.3",
        "vite-tsconfig-paths": "^5.1.4",
        "zod": "^3.24.2"
    },
    "devDependencies": {
        "@testing-library/dom": "^10.4.0",
        "@testing-library/react": "^16.2.0",
        "@types/bun": "^1.2.4",
        "@types/react": "^19.0.8",
        "@types/react-dom": "^19.0.3",
        "@vitejs/plugin-react": "^4.3.4",
        "jsdom": "^26.0.0",
        "typescript": "^5.7.2",
        "vite": "^6.1.0",
        "vitest": "^3.0.5",
        "web-vitals": "^4.2.4"
    }
}

alex-delia
PRO

10 months ago

can you try removing the node server preset from your build command?


alex-delia
PRO

10 months ago

if youre using bun you should be using the bun preset not the node preset

// app.config.ts
import { defineConfig } from '@tanstack/react-start/config'

export default defineConfig({
server: {
preset: 'bun',
},
})

// Or you can use the --preset flag with the build command
// to specify the deployment target when building the application:
// npm run build --preset bun


kevmok
PROOP

10 months ago

I see, I encounter other errors with that then


alex-delia
PRO

10 months ago

might be worth asking about over in the tanstack discord


alex-delia
PRO

10 months ago

as well


kevmok
PROOP

10 months ago

Yeah good idea - i'll do that and update this thread


kevmok
PROOP

10 months ago

I figured it out!
So I used the preset you told me and instead of using the vinxi start command i just used the raw command bun run .output/server/index.mjs


kevmok
PROOP

10 months ago

!s


alex-delia
PRO

10 months ago

nice!


alex-delia
PRO

10 months ago

glad it worked out


brody
EMPLOYEE

10 months ago

thank you zander!


brody
EMPLOYEE

10 months ago

!s


Status changed to Solved brody 10 months ago


Loading...