Description
Here is a minimal reproduction repo of the issue: https://github.com/jperasmus/repro-react-router-7-cloudflare-supabase
Steps I took to create the repro:
- Installed the Cloudflare template within this repo
- Installed
@supabase/supabase-js
- Enabled the
nodejs_compat
flag in wrangler config to allow Node.js streams - Simply
import "@supabase/supabase-js"
in the examplehome.tsx
route module - Run the app:
npm run dev
which starts up fine - Open the app in the browser, and it will crash with the following error:
node:internal/fs/promises:638
return new FileHandle(await PromisePrototypeThen(
^
Error: ENOENT: no such file or directory, open 'node:stream'
at open (node:internal/fs/promises:638:25)
at Object.readFile (node:internal/fs/promises:1242:14)
at extractExportsData (file:///xxx/node_modules/vite/dist/node/chunks/dep-Pj_jxEzN.js:18700:24) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
If you comment out the import "@supabase/supabase-js
, the problem goes away.
For my own sanity, here is another repro that uses the same @cloudflare/vite-plugin
and the Supabase import added to it. Ie. the only difference is it doesn't run via react-router dev
. This runs without any errors (after enabling nodejs_compat
of course). This leads me to believe the React Router CLI is doing something to cause the issue since it bootstraps the Vite app.
Further, if I first npm run build
and then npm run preview
on the repo using React Router, the app works. I believe this is fine since the preview is using vite preview
directly.