Module failing to load on Nuxt 3.0.0-rc.4
See original GitHub issueVersion
@nuxtjs/supabase: 0.1.17 nuxt: 3.0.0-rc.4
Reproduction Link
https://github.com/gregmulvaney/supabase_error
Steps to reproduce
- Fresh Nuxt 3 app generated with Nuxi
- Install @nuxtjs/supabase
- Add entry to Nuxt build modules
- Run nuxt dev
What is Expected?
It works
What is actually happening?
While Vite does start up, as soon as you attempt to load the site in a browser it hangs and then eventually returns a 503. Console outputs
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Use node --trace-warnings ...to show where the warning was created)
Removing @nuxtjs/supabase from the modules list fixes this error.
Update
I am amble to use the module if I run nuxt build
and nuxt preview
. Still does not work with nuxt dev
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:14 (3 by maintainers)
Top Results From Across the Web
the requested module 'untyped' does not provide an export ...
This issue is still happening and when I run npm update its throwing me this: Nuxi 3.0.0-rc.11 Nuxt 3.0.0-rc.11 with Nitro 0.5.4 ERROR...
Read more >Nuxt Cannot load payload _payload.js TypeError
I have used hash(#) in my unused link i.e <nuxt-link to="#">Link</nuxt-link> That is one of the reason I am getting error in generated...
Read more >Modules directory - Nuxt
Modules are functions that are called sequentially when booting Nuxt. The framework waits for each module to finish before continuing. In this way,...
Read more >Using Modules and Pinia to structure Nuxt 3 app
For the sake of this tutorial we will create a simple blog module that will contain it's own components, pages, composables and Pinia...
Read more >[nuxt] [request error] require is not defined in es module scope ...
Operating System: Darwin; Node Version: v17.8.0; Nuxt Version: 3.0.0-rc.1; Package Manager: yarn@1.22.18; Builder: vite; User Config: vue , head , plugins ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for making the issue and reproducing with the latest working version. I’ve managed to find the fix but worth sharing the story.
First thing first, in order to find more information about the cause of the error, as the Node.js message tells, we can use
--trace-warnings
:This means our dev bundle is importing an invalid ESM module from
@supabase/postgrest-js
. Read more in v3 Docs about invalid ESM modules.There are two entries to inspect:
.nuxt/dev/index.mjs
(nitro bundle).nuxt/server/server.mjs
(vite bundle for nuxt app) <-- issue is hereSearching for
import
andimport()
, there is the problematic import line in vite bundle:The issue is that
@supabase/postgreest-js
has filed, is using ESM syntax bu not comply with what Node.js expecting for ESM code to use.mjs
extension ortype: "module"
in nearest package.json. Now with Nuxt 3, we took some smart ideas to automatically detect this situation and inline the dependency using vite or rollup that can handle such mixed syntax. (unjs/externality and unjs/mlly#isValidNodeImport).This was automatically working until
postgrest-js@0.37.3
because types.js had an import statement but in0.37.4
that import was removed and regex in mlly wasn’t enough to cover onlyexport class PostgrestBuilder
So how is the fix and steps:
@supabase/
packages explicitly to theebuild.transpile
step to avoid such regressions when automated detector doesn’t works.export class
and categorize as ESM (https://github.com/unjs/mlly/commit/896c8a7dd087d041ffb29a00065a4f71d62ed249)@supabase
libraries to fix ESM issue. Solution is as easy as adding a package.json to thedist/module/
withtype: module
or (much better) use.mjs
/.cjs
syntax.After digging a lot in sub dependencies, I finally found the guilty. I’ll soon provide a release to fix it. To fix it temporary, can you try to add a
resolutions
field in yourpackage.json
with: