question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Nuxt 3 rc 3 - Cloudflare Preset] ReferenceError: Cannot access '**' before initialization

See original GitHub issue

Been trying to debug this issue for a few days, after I did a upgrade on all the packages. Then now I’m getting reference error, when having built with the Cloudflare preset, and either trying to publish or testing with Miniflare.

In the built file it happens in this area ii={..._,...k,...ii,promises:oi}, but overall, I don’t have enough knowledge to track down where exactly this stems from. Only found out that it only happens when this module is being used. If I comment out this in the nuxt config module section, everything works as normal.

Posting here as a start, as it’s the closest I’ve gotten to where the error comes from.

Version

  • Operating System: Darwin
  • Node Version: v18.1.0
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: modules, nitro
  • Runtime Modules: @nuxtjs/supabase@0.1.14
  • Build Modules: -

Reproduction Link

https://github.com/PhaxeNor/nuxt-supabase-test Make sure to create the .env file

SUPABASE_URL="https://example.supabase.com"
SUPABASE_KEY="<your_key>"

Steps to reproduce

  1. Install latest Nuxt 3 dev ^3.0.0-rc.3 and latest supabase module 0.1.14

  2. Set up according to docs

  3. Build using Cloudflare Preset

  4. Run with Miniflare/try publish

  5. See error in console about ReferenceError

  6. Remove @nuxtjs/supabase from the nuxt config module section

  7. Repeat steps 3-4, then see it working.

What is Expected?

Being able to run and use the Supabase module with Cloudflare, as it worked a few weeks ago

What is actually happening?

After setting up a project and adding @nuxtjs/supabase, and setting it up according to the docs, then building using the Cloudflare preset provided with Nuxt3, it throws the ReferenceError when trying to run that build

Full Error

ReferenceError: Cannot access 'ii' before initialization
    at ctx (/Users/PhaxeNor/Development/Test/NuxtSupabaseTest/node_modules/unenv/runtime/node/fs/index.mjs:12:6)
    at /Users/PhaxeNor/Development/Test/NuxtSupabaseTest/.nuxt/dist/server/server.mjs:12507:32
    at Script.runInContext (node:vm:139:12)
    at VMScriptRunner.runAsScript (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/runner-vm/src/index.ts:25:12)
    at VMScriptRunner.run (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/runner-vm/src/index.ts:84:12)
    at Miniflare.#reload (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/core/src/index.ts:737:42)
    at Miniflare.getPlugins (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/core/src/index.ts:970:5)
    at createServer (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/http-server/src/index.ts:334:19)
    at startServer (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/@miniflare/http-server/src/index.ts:420:18)
    at main (/Users/PhaxeNor/.npm/_npx/46ed1b29b205fa85/node_modules/miniflare/src/cli.ts:96:5)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
adrianciacobcommented, Jul 12, 2022

Any update on this ? workaround ? completely blocked on updating cloudflare env to latest nuxt3 @danielroe @pi0

2reactions
danielroecommented, May 16, 2022

This looks like it’s related how we are mocking fs in unenv: https://github.com/unjs/unenv/commit/5ee4115ca87406158bed4b2c2419532c1e311a60

Also will need to investigate why debug is being inlined, which seems the source of why we’re inlining fs.

cc: @pi0

Read more comments on GitHub >

github_iconTop Results From Across the Web

NITRO_PRESET=cloudflare - nuxt build generates code with ...
Now I see another issue related to image module. We cannot deploy it to cloudflare workers because IPX and Sharp (built-in image optimizer) ......
Read more >
node.js - ReferenceError: Cannot access 'fs' before initialization
The error means that you're trying to use the variable fs BEFORE its const fs ... ReferenceError: Cannot access 'fs' before initialization.
Read more >
[SOLVED] Cannot Access Before Initialization Error in JavaScript
The “cannot access before initialization” reference error occurs in JavaScript when you try to access a variable before it is declared with let ......
Read more >
Roadmap | Nuxt Supabase
Discover our kaban board for the next release of the Supabase module. ... [Nuxt 3 rc 3 - Cloudflare Preset] ReferenceError: Cannot access...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/24 17 ...
Bug:128538 - "sys-apps/coreutils: /bin/hostname should be installed from coreutils not sys-apps/net-tools" status:UNCONFIRMED resolution: severity:enhancement ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found