supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
363 stars 163 forks source link

Error SyntaxError: The requested module does not provide an export named 'default' after install #648

Closed D4rkMindz closed 1 year ago

D4rkMindz commented 1 year ago

Bug report

Describe the bug

After installing supabase, I receive the error message "Uncaught SyntaxError: The requested module '/_nuxt/node_modules/crypto-js/sha256.js?v=98406020' does not provide an export named 'default'". The error seems to originate from the helpers.ts file

To Reproduce

Install nuxt and nuxt/supabase.

my package.json

{
  "private": true,
  "overrides": {
    "vue": "latest"
  },
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "extract-translations": "vue-i18n-extract report --vueFiles './{components,composables,helpers,layouts,middleware,pages,public,stores}/**/*.?(js|vue)' --languageFiles './locales/*.?(json|yml|yaml|js)' --add"
  },
  "devDependencies": {
    "@heroicons/vue": "^2.0.8",
    "@nuxtjs/i18n": "^8.0.0-beta.9",
    "@nuxtjs/supabase": "0.3.0",
    "@nuxtjs/tailwindcss": "^6.1.3",
    "@pinia-plugin-persistedstate/nuxt": "^1.0.0",
    "@tailwindcss/typography": "^0.5.4",
    "autoprefixer": "^10.4.8",
    "daisyui": "^2.24.0",
    "nuxt": "^3.3.1",
    "postcss": "^8.4.16",
    "sass": "^1.56.2",
    "tailwindcss": "^3.1.8",
    "vue-i18n-extract": "^2.0.7"
  },
  "dependencies": {
    "@pinia/nuxt": "^0.4.6",
    "pinia": "^2.0.33",
    "theme-change": "^2.2.0",
    "vee-validate": "^4.6.9",
    "yup": "^0.32.11"
  }
}

my nuxt config

export default defineNuxtConfig({
    runtimeConfig: {
        public: {
            apiURL: "https://api.test"
        }
    },
    imports: {
        autoImport: true,
        dirs: [
            'composables/**'
        ]
    },
    modules: [
        '@nuxtjs/supabase',
        '@nuxtjs/tailwindcss',
        // disabled color mode since it will cause the theme "garden" to be always default... (what a WTF bug)
        // '@nuxtjs/color-mode',
        ['@pinia/nuxt', {
            autoImports: [
                // automatically imports `defineStore`
                'defineStore', // import { defineStore } from 'pinia'
                // automatically imports `defineStore` as `definePiniaStore`
                ['defineStore', 'definePiniaStore'], // import { defineStore as definePiniaStore } from 'pinia'
            ],
        }],
        '@pinia-plugin-persistedstate/nuxt',
        '@nuxtjs/i18n',
    ],
    build: {
        transpile: ['@heroicons/vue']
    },
    i18n: {
        locales: [
            {
                code: 'en',
                name: 'English',
                file: 'en.json',
            },
            {
                code: 'de',
                name: 'Deutsch',
                file: 'de.json',
            },
        ],
        // lazy: true,
        langDir: './locales/',
        defaultLocale: 'en',
        vueI18n: {
            fallbackLocale: 'en',
            legacy: false,
        }
    }
})

Expected behavior

To not throw an Error

Screenshots

Bildschirm­fotoe 2023-03-31 um 14 38 06

System information

D4rkMindz commented 1 year ago

Whenever I comment the line '@nuxtjs/supabase' in the nuxt config modules ("remove supabase" from the project) it starts working again. Therefore, the reason MUST be supabase itself.

Edit 01.04.2023: This error causes the JS execution to stop. Since the error occurs during the boot process, it prevents and blocks any further execution (and therefore development too).

bobbyrahmanda13 commented 1 year ago

this is bug or not , i also get the same thing help me image

how i can fix this

D4rkMindz commented 1 year ago

You cannot fix it until a new version containing the fix is released.

D4rkMindz commented 1 year ago

There is a quick fix: For Yarn

  "resolutions": {
    "@supabase/gotrue-js": "2.16.0"
  },

For NPM, you could use

  "overrides": {
    "@supabase/gotrue-js": "2.16.0"
  },
bobbyrahmanda13 commented 1 year ago

not working image image

larbish commented 1 year ago

It should be fixed in v0.3.5 of the Nuxt Supabase Module.

bobbyrahmanda13 commented 1 year ago

thanks solved upgrade to v0.3.5 @nuxtjs/supabase

silentworks commented 1 year ago

We removed this dependency from the gotrue-js library which should resolved the issue.

Aietes commented 1 year ago

I'm not sure if this is related, but seems very close:

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

It seems to come from import crossFetch from 'cross-fetch' in PostgrestBuilder.ts, and should be related to the supabase-js package.

Psycarlo commented 3 weeks ago

I uninstalled and installed @nuxtjs/supabase (using pnpm instead of nuxi)