matrix-js-sdk icon indicating copy to clipboard operation
matrix-js-sdk copied to clipboard

global is not defined (Nuxt)

Open muffincode opened this issue 1 year ago • 0 comments

Hi, I'm using [email protected] in a Nuxt app and encounter this error when loading the app

Uncaught ReferenceError: global is not defined (NuxtJS 15
[matrix-js-sdk.js:180169:9](http://localhost:3000/_nuxt/node_modules/.cache/vite/client/deps/matrix-js-sdk.js?v=52b26584))

I can fix this by changing the Vite config as such:

// in nuxt.config.js
  vite: {
    define: {
      global: 'window'
    },
  },

Then, serving the project locally works fine, but when building, it seems to replace all instances of "global" in the filenames etc, breaking the build.

For example, the component stored in components/global/buttons/button-text.vue

 ERROR  [vite:vue] Could not load /home/xxx/yyy/components/window/button/button-text.vue?vue&type=style&index=0&scoped=5bbaaa36&lang.css (imported by components/global/button/button-text.vue): ENOENT: no such file or directory, open '/home/xxx/yyy/components/window/button/button-text.vue'

is there any other way to give the sdk what it wants without changing the vite config?

muffincode avatar Dec 21 '23 09:12 muffincode