Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarianMichalovic opened this issue Nov 29, 2022 · 6 comments
Labels
bug Something isn't working cloudflare Stale

Comments

@MarianMichalovic
Copy link

Version

@nuxtjs/supabase: 0.3.0
nuxt: 3.0.0

Cloudflare Workers:

  • wrangler deploy failed
    ReferenceError: global is not defined

Vercel Edge

  • after deploy
    ReferenceError: global is not defined

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

@MarianMichalovic MarianMichalovic added the bug Something isn't working label Nov 29, 2022
@kevcodez
Copy link

kevcodez commented Dec 3, 2022

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
Copy link
Author

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
Copy link

Zebnastien commented Feb 25, 2023

Same here : #158

@xmatthias
Copy link

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.

Copy link

github-actions bot commented May 6, 2025

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label May 6, 2025
Copy link

github-actions bot commented Jun 5, 2025

This issue was closed because it has been stalled for 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cloudflare Stale
Projects
None yet
Development

No branches or pull requests

5 participants