T
TanStack7mo ago
absent-sapphire

cloudflare deployment error: No such module 'node:http' imported from 'chunks/nitro/nitro.mjs

I get the error below when I try to deploy to cloudflare pages:
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "node:http".
imported from "chunks/nitro/nitro.mjs"
Error: Failed to publish your Function. Got error: Uncaught Error: No such module "node:http".
imported from "chunks/nitro/nitro.mjs"
Has anyone experienced this? I followed the deployment instruction from the docs https://tanstack.com/start/latest/docs/framework/react/hosting#cloudflare-pages // app.config.ts
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from '@tanstack/start/config';
import { cloudflare } from 'unenv';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
preset: 'cloudflare-pages',
unenv: cloudflare,
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tailwindcss(),
],
},
});
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from '@tanstack/start/config';
import { cloudflare } from 'unenv';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
server: {
preset: 'cloudflare-pages',
unenv: cloudflare,
},
vite: {
plugins: [
tsConfigPaths({
projects: ['./tsconfig.json'],
}),
tailwindcss(),
],
},
});
wrangler.toml
name = "my-app"
pages_build_output_dir = "./dist"
compatibility_flags = ["nodejs_compat"]
compatibility_date = "2024-11-13"
name = "my-app"
pages_build_output_dir = "./dist"
compatibility_flags = ["nodejs_compat"]
compatibility_date = "2024-11-13"
package.json
{
"name": "my-app",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"dev": "vinxi dev",
"build": "vinxi build",
"start": "vinxi start"
},
"dependencies": {
"@tanstack/react-router": "1.105.0",
"@tanstack/start": "1.105.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"unenv": "^1.10.0",
"vinxi": "0.5.3"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.6",
"@types/react": "^19.0.9",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "5.7.3",
"vite-tsconfig-paths": "5.1.4"
}
}
{
"name": "my-app",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"dev": "vinxi dev",
"build": "vinxi build",
"start": "vinxi start"
},
"dependencies": {
"@tanstack/react-router": "1.105.0",
"@tanstack/start": "1.105.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"unenv": "^1.10.0",
"vinxi": "0.5.3"
},
"devDependencies": {
"@tailwindcss/vite": "^4.0.6",
"@types/react": "^19.0.9",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "5.7.3",
"vite-tsconfig-paths": "5.1.4"
}
}
Is it normal to have imports like below in dist/_worker.js/chunks/nitro/nitro.mjs ?
import * as node_http from 'node:http';
import * as node_https from 'node:https';
import * as node_zlib from 'node:zlib';
import * as node_stream from 'node:stream';
import { PassThrough, Readable as Readable$1 } from 'node:stream';
import * as node_buffer from 'node:buffer';

...
import * as node_http from 'node:http';
import * as node_https from 'node:https';
import * as node_zlib from 'node:zlib';
import * as node_stream from 'node:stream';
import { PassThrough, Readable as Readable$1 } from 'node:stream';
import * as node_buffer from 'node:buffer';

...
Hosting | TanStack Start React Docs
Hosting is the process of deploying your application to the internet so that users can access it. This is a critical part of any web development project, ensuring your application is available to the...
7 Replies
other-emerald
other-emerald7mo ago
Hello! I'm encountering the same issue. I opened a thread on this with a minimal repo to reproduce it and going to open a Github issue soon if I can't solve first. From what I've experienced, downgrading to 1.81 solves it. I found this Github issue to be related if you're interested.
GitHub
Code Splitting Issues with TanStack Start and Cloudflare Pages Depl...
Which project does this relate to? Start Describe the bug I'm experiencing issues with code splitting when deploying a TanStack Start project to Cloudflare Pages. The application appears to be ...
unwilling-turquoise
unwilling-turquoise7mo ago
Facing the same issue,
wise-white
wise-white7mo ago
was getting it and fixed by wrapping my node code in createServerFn. -- previously i was calling certain nodejs apis inside of a routeloader wrapped in if(typeof window === 'undefined') this prevented it at crashing during dev mode at runtime, but caused problems during the build
unwilling-turquoise
unwilling-turquoise7mo ago
i do not have any build time issues, this only happens when it builds for cloudflare, it builds successfully but fails to deploy on cloudflare pages.
vicious-gold
vicious-gold7mo ago
same issue
psychological-ivory
psychological-ivory7mo ago
facing the same issue , trying to upload the basic example
unwilling-turquoise
unwilling-turquoise7mo ago
I'm unable to release the new version of my webapp

Did you find this page helpful?