T
TanStack3mo ago
metropolitan-bronze

Getting error deploying Cloudflare worker

I am using tanstack start version 1.121.26 Vite plugin here is my vite.conf.ts
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
server: {
port: 3000,
},
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tanstackStart({
target: "cloudflare-worker"
}),
tailwindcss(),
],
})
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from 'vite'
import tsConfigPaths from 'vite-tsconfig-paths'

export default defineConfig({
server: {
port: 3000,
},
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tanstackStart({
target: "cloudflare-worker"
}),
tailwindcss(),
],
})
Here is my wrangler.jsonc
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "nasimdev",
"main": "./.output/server/index.mjs",
"compatibility_date": "2025-04-14",
"observability": {
"enabled": true
},
"assets": {
"directory": "./.output/public/"
},
"compatibility_flags": [
"nodejs_compat"
]
}
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "nasimdev",
"main": "./.output/server/index.mjs",
"compatibility_date": "2025-04-14",
"observability": {
"enabled": true
},
"assets": {
"directory": "./.output/public/"
},
"compatibility_flags": [
"nodejs_compat"
]
}
Getting error while running npx wrangler deploy
[ERROR] Build failed with 1 error:

[ERROR] Unexpected external import of "node:events",
"node:perf_hooks", "node:stream", and "node:tty".
Your worker has no default export, which means it is assumed to be a Service Worker format Worker.
Did you mean to create a ES Module format Worker?
If so, try adding `export default { ... }` in your entry-point.
See https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/.
[plugin hybrid-nodejs_compat]
[ERROR] Build failed with 1 error:

[ERROR] Unexpected external import of "node:events",
"node:perf_hooks", "node:stream", and "node:tty".
Your worker has no default export, which means it is assumed to be a Service Worker format Worker.
Did you mean to create a ES Module format Worker?
If so, try adding `export default { ... }` in your entry-point.
See https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/.
[plugin hybrid-nodejs_compat]
Am I missing something, or does anyone have the same problem? Help me, please.
2 Replies
fascinating-indigo
fascinating-indigo3mo ago
The target is called cloudflare-module and not cloudflare-worker. You can also add the "compatibility_flags": ["nodejs_compat"], flag to your wrangler.jsonc file.
metropolitan-bronze
metropolitan-bronzeOP3mo ago
Worked like a charm, Thanks

Did you find this page helpful?