rc start cloudflare fails to build and deploy #5213
Send to my agentWhich project does this relate to?#
Start
Describe the bug#
build error: node_modules/.pnpm/@tanstack+devtools@0.6.14_csstype@3.1.3_solid-js@1.9.9/node_modules/@tanstack/devtools/dist/devtools/EZ6UNLQL.js (2:60): "use" is not exported by "node_modules/.pnpm/solid-js@1.9.9/node_modules/solid-js/web/dist/server.js", imported by "node_modules/.pnpm/@tanstack+devtools@0.6.14_csstype@3.1.3_solid-js@1.9.9/node_modules/@tanstack/devtools/dist/devtools/EZ6UNLQL.js".
If the build succeeds, deploy:dry-run shows error: X [ERROR] Build failed with 5 errors:X [ERROR] Could not resolve "#tanstack-router-entry"
Your Example Website or App#
https://codesandbox.io/p/github/axuj/tanstack-start-cloudflare/master
Steps to Reproduce the Bug or Issue#
run: build deploy:dry-run
Expected behavior#
build and deploy successful
Screenshots or Videos#
No response
Platform#
- Router / Start Version: 1.132.2
- OS: windows,sandbox
- Browser: [e.g. Chrome, Safari, Firefox]
- Browser Version: [e.g. 91.1]
- Bundler: [e.g. vite]
- Bundler Version: [e.g. 7.0.0]
Additional context#
No response
this is most likely caused by the devtools. try removing them to check please
Try upgrading Router / Start Version to 1.132.6 and changing the
wrangler.jsonfile// wrangler.json - "main": "./src/server.ts", + "main": "@tanstack/react-start/server-entry",This in combination with the cloudflare vite environment configuration allowed me to successfully run
vite buildwranger devandwranger deploy// vite.config.ts cloudflare({ viteEnvironment: { name: "ssr" }, }),this is most likely caused by the devtools. try removing them to check please
It is indeed an issue with DevTools. I have restricted DevTools to the development client. Although an error is reported during development, it remains usable. Thank you for your work—now "start" can be used together with Durable Objects. I have added the relevant code to the example for others' reference.
this is most likely caused by the devtools. try removing them to check please
It is indeed an issue with DevTools. I have restricted DevTools to the development client. Although an error is reported during development, it remains usable. Thank you for your work—now "start" can be used together with Durable Objects. I have added the relevant code to the example for others' reference.
could you share your working
wrangler.jsonc,vite.config.ts, andserver.tsif you don't mind?i kept getting stuck at
The entry-point file at "@tanstack/react-start/server-entry" was not found.when running it withwrangler devand kinda clueless about where do i need to look atthis is most likely caused by the devtools. try removing them to check please
It is indeed an issue with DevTools. I have restricted DevTools to the development client. Although an error is reported during development, it remains usable. Thank you for your work—now "start" can be used together with Durable Objects. I have added the relevant code to the example for others' reference.
could you share your working
wrangler.jsonc,vite.config.ts, andserver.tsif you don't mind?i kept getting stuck at
The entry-point file at "@tanstack/react-start/server-entry" was not found.when running it withwrangler devand kinda clueless about where do i need to look athttps://codesandbox.io/p/github/axuj/tanstack-start-cloudflare/master CodeSandbox may have a cache, and you can directly view the source - code repository. https://github.com/axuj/tanstack-start-cloudflare
@axuj found your repo here: https://github.com/axuj/tanstack-start-cloudflare
is that deploying for you? when i run
pnpm run deployim getting these errors: https://github.com/TanStack/router/issues/5196@axuj found your repo here: https://github.com/axuj/tanstack-start-cloudflare
is that deploying for you? when i run
pnpm run deployim getting these errors: #5196i can deploy
I ran into the same issue using bun
error during build: node_modules/@tanstack/devtools/dist/devtools/EZ6UNLQL.js (2:60): "use" is not exported by "node_modules/solid-js/web/dist/server.js", imported by "node_modules/@tanstack/devtools/dist/devtools/EZ6UNLQL.js".Removing the devtools did fix the issue for me.
My wrangler and vite are updated with the suggestions here
My app is a react app, so I'm not sure why it's trying to import the solid-js tools
deploys locally via wrangler deploy but cloud builds (github hook) fails because there is an error in the build
error during build: TypeError: Cannot read properties of undefined (reading 'compatibilityFlags') at file:///.../apps/web/dist/server/assets/worker-entry-BlBQ3mvS.js:352:50 at ModuleJob.run (node:internal/modules/esm/module_job:329:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:644:26) at async prerender (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:50:41) at async postServerBuild (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:39:5) at async Object.buildApp (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:200:15) at async Object.buildApp (file:///.../node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:34216:38) at async CAC.<anonymous> (file:///.../node_modules/vite/dist/node/cli.js:641:3) ELIFECYCLE Command failed with exit code 1.deploys locally via wrangler deploy but cloud builds (github hook) fails because there is an error in the build
error during build: TypeError: Cannot read properties of undefined (reading 'compatibilityFlags') at file:///.../apps/web/dist/server/assets/worker-entry-BlBQ3mvS.js:352:50 at ModuleJob.run (node:internal/modules/esm/module_job:329:25) at async onImport.tracePromise.proto (node:internal/modules/esm/loader:644:26) at async prerender (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:50:41) at async postServerBuild (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/post-server-build.js:39:5) at async Object.buildApp (file:///.../node_modules/@tanstack/start-plugin-core/dist/esm/plugin.js:200:15) at async Object.buildApp (file:///.../node_modules/vite/dist/node/chunks/dep-Bm2ujbhY.js:34216:38) at async CAC. (file:///.../node_modules/vite/dist/node/cli.js:641:3) ELIFECYCLE Command failed with exit code 1.
This looks related to Cloudflare & pre-rendering? I had issues with that too.
I was able to workaround my problem by updating
vite.config.js:... define: { "globalThis.Cloudflare.compatibilityFlags": "{enable_nodejs_process_v2: true}", }, ...... define: { "globalThis.Cloudflare.compatibilityFlags": "{enable_nodejs_process_v2: true}", }, ...
thanks this indeed resolved it and yes I have some pre-rendered pages 👍
edit: this caused more problems the output html gets broken and at the bottom of the page there is html code as text outputted randomly
@orenaksakal prerendering is not yet supported with the cloudflare vite plugin.
can you please share a complete example that breaks with the above issue?
@orenaksakal prerendering is not yet supported with the cloudflare vite plugin.
can you please share a complete example that breaks with the above issue?
Okay I've disabled prerendering for now here is my vite.config.ts causing the issue mentioned above
export default defineConfig({ define: { "globalThis.Cloudflare.compatibilityFlags": { enable_nodejs_process_v2: true, }, }, plugins: [ cloudflare({ viteEnvironment: { name: "ssr" }, }), tsconfigPaths(), tailwindcss(), generateSitemap(sitemap), tanstackStart({ pages: [ { path: "/blog", prerender: { enabled: true, outputPath: "/blog/index.html" }, }, ], }), viteReact(), ], });this is the wrangler.jsonc
/** * For more details on how to configure Wrangler, refer to: * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { "$schema": "node_modules/wrangler/config-schema.json", "name": "redacted-web", "main": "@tanstack/react-start/server-entry", /** * Nodejs support */ "compatibility_date": "2025-09-25", "compatibility_flags": ["nodejs_compat"], /** * Logs */ "observability": { "enabled": true }, "logpush": true, /** * Custom Domains */ "routes": [ { "pattern":"www.redacted.com", "custom_domain": true }, { "pattern": "redacted.com", "custom_domain": true } ], /** * Execution limit for safety */ "limits": { "cpu_ms": 30000 }, /** * Smart Placement * Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement */ // "placement": { // "mode": "smart" // }, /** * Bindings * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including * databases, object storage, AI inference, real-time communication and more. * https://developers.cloudflare.com/workers/runtime-apis/bindings/ */ /** * Environment Variables * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables */ "vars": { "PUBLIC_VITE_SERVER_URL": "https://server.redacted.com" }, "version_metadata": { "binding": "CF_VERSION_METADATA" } /** * Note: Use secrets to store sensitive data. * https://developers.cloudflare.com/workers/configuration/secrets/ */ /** * Static Assets * https://developers.cloudflare.com/workers/static-assets/binding/ */ // "assets": { "directory": "./public/", "binding": "ASSETS" } /** * Service Bindings (communicate between multiple Workers) * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings */ // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] }but how does your route look like that during prerendering caused the error?
I will see if I can share a public repo with minimal repro later on but it is a simple app, on landing page at the footer random code was rendered as text often duplicated (html code as text on the page)
I am having the same issue when trying to use wrangler-action. Not sure how to resolve this.
If you are having issues - this config may work for you (it works for me so far). After build you should have everything is dist folder in this case
{ "$schema": "node_modules/wrangler/config-schema.json", "name": "xxxxx", "compatibility_date": "2025-09-02", "compatibility_flags": ["nodejs_compat"], "main": "./dist/server/server.js", "env": { "production": { "vars": { .... } } }, "routes": [ { "pattern": "aaa.bbbb", "custom_domain": true } ], "observability": { "enabled": true }, "assets": { "directory": "./dist/client/" } }@orenaksakal prerendering is not yet supported with the cloudflare vite plugin.
do we have an eta for when this is coming?
With
”@tanstack/react-start”: “^1.132.0”, I confirmed that build and deploy work correctly using the settings below.src/server.ts
import handler from "@tanstack/react-start/server-entry"; export default { fetch(request: Request) { return handler.fetch(request); }, };wrangler.json
{ "name": "tanstack-start-app", "main": "./src/server.ts", "compatibility_date": "2025-08-13", "compatibility_flags": ["nodejs_compat_v2"], }closing this as CF deployment works. if anyone encounters a similar issue that is not resolved by following the hints above, then please create a new github issue including a complete minimal reproducer
I just ran into this, its the new devtools causing the issue:
[ERROR] The entry-point file at "@tanstack/react-start/server-entry" was not found.Setup server entry point outlined here:
With
”@tanstack/react-start”: “^1.132.0”, I confirmed that build and deploy work correctly using the settings below.// src/server.ts import handler from "@tanstack/react-start/server-entry";
export default { fetch(request: Request) { return handler.fetch(request); }, };
// wrangler.json { "name": "tanstack-start-app", "main": "./src/server.ts", "compatibility_date": "2025-08-13", "compatibility_flags": ["nodejs_compat_v2"], }
Then setup devtools the tradtional way outlined here.
This new devtools breaks it: https://tanstack.com/devtools/latest/docs/quick-start
TL;DR#
I needed to add install and build steps before
cloudflare/wrangler-action@v3task:- uses: actions/checkout@v4 - run: npm ci - run: npm run build - name: Deploy Cloudflare Workers uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}Full investigation#
+ handling secret env variables in CLoudflare worker#
After playing around, I have removed file that was created only locally (git ignored):
.wrangler/deploy/config.json, which has following contents:{ "configPath": "..\\..\\dist\\server\\wrangler.json", "auxiliaryWorkers": [] }I wondered, what would be the effect of removing such file. To my surprise, after removing the file and running locally
wrangler deployI could reproduce the error I was getting in the Github Action!The entry-point file at "@tanstack/react-start/server-entry" was not found.
So, it was clear indicator that wrangler can't actually find appropriate configuration file.
So I decided to start from scratch with my Github Action YML file:
name: Deploy on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest name: Deploy steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '25' - run: npm install -g wrangler - run: ls -la - run: wrangler deploy --config ./dist/server/wrangler.json env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}I used
ls -lato see what I had available after checkout.It yielded expectedly that I don't have
.wranglerdirectory, so noconfig.json.However above script failed, as it was missing
npm ciandnpm buildcommands, that produce the outputdistdirectory.After adding them:
... - run: npm install -g wrangler - run: npm ci - run: npm run build - run: wrangler deploy --config ./dist/server/wrangler.json ...the whole script run successfully and deployed the app to Cloudflare correctly!
IMPORTANT NOTE: wrangler deployment removes environment variables set in the worker, so we need to pass
--keep-varsin order to preserve set environment variables.EDIT
Inspired by my success I thought that I could make
cloudflare/wrangler-action@v3run correctly with below adjustmentsname: Deploy Worker on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest timeout-minutes: 60 steps: - uses: actions/checkout@v4 - name: Build & Deploy Worker uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: deploy --config ./dist/server/wrangler.jsonbut it complained about
dist/server/wrangler.jsonfile not present.So, learning from my implementation using raw CLI commands, I have added steps
npm ciandnpm run build, which made whole thing work.After all, I ended up with YML that was almost the same as in the docs, but with added
npm ciandnpm run buildcommands:name: Deploy Worker on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest timeout-minutes: 60 name: Build App and Deploy Cloudflare Worker steps: - uses: actions/checkout@v4 - run: npm ci - run: npm run build - name: Deploy Cloudflare Workers uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}However, this also removes any environment variables from Worker. I tried using
secretsparameter passed tocloudflare/wrangler-action@v3action.Additionally, any environment variables that are potentially used in HTML/client bundle, need to be passed to
npm run buildstep, as at this stage some static HTML might be already generated, and if it references any environment variables, we need to provide them it in this step.Below is final, fully working Github Action YML, with setting correctly env variables at build time and also correctly setting env variables in Cloudflare Worker:
name: Deploy Worker on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest timeout-minutes: 60 name: Build App and Deploy Cloudflare Worker steps: - uses: actions/checkout@v4 - run: npm ci # At this step, some static HTML is generated, so it needs environment variables # that could be used in client bundle. - run: npm run build env: VITE_RECAPTCHA_SITE_KEY: ${{ secrets.VITE_RECAPTCHA_SITE_KEY }} - name: Deploy Cloudflare Workers uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} secrets: | RECAPTCHA_SECRET_KEY VITE_RECAPTCHA_SITE_KEY env: RECAPTCHA_SECRET_KEY: ${{ secrets.RECAPTCHA_SECRET_KEY }} VITE_RECAPTCHA_SITE_KEY: ${{ secrets.VITE_RECAPTCHA_SITE_KEY }}
Sign in to join this conversation.
I've the same issue! but I'm using bun avoid pnpm