Skip to content
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

Export named 'default' is not provided #120

Open
lukaszflorczak opened this issue Dec 17, 2021 · 6 comments
Open

Export named 'default' is not provided #120

lukaszflorczak opened this issue Dec 17, 2021 · 6 comments
Labels

Comments

@lukaszflorczak
Copy link

Hey.

I'm trying to use supabase (which uses cross-fetch) with Nuxt 3 and I found a problem with browser-ponyfill:

Uncaught SyntaxError: The requested module '/node_modules/cross-fetch/dist/browser-ponyfill.js?v=6f3da668' does not provide an export named 'default'

More info about ES modules in Nuxt 3: https://v3.nuxtjs.org/concepts/esm

@eMeRiKa13
Copy link

I have exactly the same problem since I updated my dependencies some days ago.

What can we do to fix that?

@eMeRiKa13
Copy link

eMeRiKa13 commented Jan 4, 2022

On the Nuxt3 Discord server someone game me the solution:

In nuxt.config.ts

build: {
  transpile: ['@supabase', 'cross-fetch']
}

But now I have this error #108. I think this lib is not compatible with Vite due to the deprecation of require for import.

@lukaszflorczak
Copy link
Author

lukaszflorczak commented Jan 7, 2022

Temporary, I tried to use patch-package and patch like that:

diff --git a/node_modules/cross-fetch/dist/browser-ponyfill.js b/node_modules/cross-fetch/dist/browser-ponyfill.js
index f26eb09..a89e834 100644
--- a/node_modules/cross-fetch/dist/browser-ponyfill.js
+++ b/node_modules/cross-fetch/dist/browser-ponyfill.js
@@ -545,10 +545,12 @@ delete __self__.fetch.polyfill;
 // Choose between native implementation (global) or custom implementation (__self__)
 // var ctx = global.fetch ? global : __self__;
 var ctx = __self__; // this line disable service worker support temporarily
-exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
-exports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.
-exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
-exports.Headers = ctx.Headers
-exports.Request = ctx.Request
-exports.Response = ctx.Response
-module.exports = exports
+// exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
+// exports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.
+// exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
+// exports.Headers = ctx.Headers
+// exports.Request = ctx.Request
+// exports.Response = ctx.Response
+// module.exports = exports
+
+export default ctx
\ No newline at end of file

In transpile I have only '@supabase'.


EDIT: @eMeRiKa13 Finally I used nuxt3-supabase. In nuxt.config.ts I added:

// ...
import { fetch } from 'ohmyfetch'

export default defineNuxtConfig({
  // ...
  supabase: {
    supabaseUrl: process.env.SUPABASE_URL,
    supabaseKey: process.env.SUPABASE_KEY,
    supabaseOptions: { fetch }
  }
)}

The first usage example from nuxt3-supabase documentation doesn't work for me ($supabase is undefined), but it looks the composable method works fine.

@eMeRiKa13
Copy link

Thank for your answer. At the end, I have just removed both transpile and it's now working transpile : ['@supabase', 'cross-fetch']

For the Supabase integration, I'm using what Atinux, the Nuxt's creator, showcased here nuxt/framework#2058

@lukaszflorczak
Copy link
Author

Nice, thank you for that. I'll test it.


@lquixada Sorry for the offtopic

@lquixada lquixada added the esm label May 30, 2023
@Mo0nbase
Copy link

Mo0nbase commented Jul 3, 2023

I've just discovered the same issue however this time with the Qwik framework. Any ideas on how to triage this?

PostgrestBuilder.ts:1 Uncaught (in promise) SyntaxError: The requested module '/node_modules/.pnpm/cross-fetch@3.1.8/node_modules/cross-fetch/dist/browser-ponyfill.js?v=c3dac3ef' does not provide an export named 'default' (at PostgrestBuilder.ts:1:8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants