nuxt-modules / supabase

Supabase module for Nuxt.
https://supabase.nuxtjs.org
MIT License
739 stars 130 forks source link

Vercel Edge, Cloudflare Workers, ReferenceError: global is not defined #120

Open MarianMichalovic opened 2 years ago

MarianMichalovic commented 2 years ago

Version

@nuxtjs/supabase: 0.3.0 nuxt: 3.0.0

Cloudflare Workers:

Vercel Edge

In project only @nuxtjs/supabase package. Without @nuxtjs/supabase with supabase-js works correct.

kevcodez commented 1 year ago

Running into this, too. Here's a repo to reproduce this: https://github.com/kevcodez/nuxt-on-the-edge

Fork and deploy that to Vercel and open the page.

ReferenceError: global is not defined
    at worker.js:21:39244
    at worker.js:14:173
    at fn (worker.js:53:15532)
    at Object.<anonymous> (worker.js:57:5)
    at Object.<anonymous> (worker.js:59:6)
    at De (worker.js:77:13740)
    at worker.js:77:15871
MarianMichalovic commented 1 year ago

Cloudflare workers require node_compat = true in wrangler.toml https://developers.cloudflare.com/workers/wrangler/configuration/#node-compatibility

image

With this setup it works.

Zebnastien commented 1 year ago

Same here : https://github.com/nuxt-modules/supabase/issues/158

xmatthias commented 7 months ago

I've encountered the same problem on cloudflare after migrating from yarn to pnpm (deployment failed ... even with 0 code). Turns out, it's caused by the way pnpm is isolating packages - which is why it's working fine on yarn, but not with pnpm.

adding public-hoist-pattern[]=@supabase/supabase-js* to .npmrc does seem to fix this for me on cloudflare workers - at least with "@nuxtjs/supabase": "^1.2.0" (no other workarounds applied).

if i'll still encounter problems down the road, i'm not sure - but for me, i got the "global is not defined" error already on deployment, at the "Deploying to Cloudflare's global network" step.