scholtz / qrcode-vue3

MIT License
86 stars 32 forks source link

self is not defined #10

Open ArgekarStudios opened 2 years ago

ArgekarStudios commented 2 years ago

ReferenceError: self is not defined at Object. (/node_modules/.pnpm/qrcode-vue3@1.4.17_vue@3.2.26/node_modules/qrcode-vue3/lib/index.js:1:248)

waysagency commented 1 year ago

Any update on this? I have the same issue...

wwwDESIGN-basti commented 1 year ago

same here on ssr.

Katie-Adams commented 1 year ago

Same here. We're running the project locally as an SPA but it'll be SSR when it hits prod. The person who initially did the work has devved it with no issues but when we check out their branch and try to run the project, we see this error.

KyleSmith0905 commented 1 year ago

I added the following to nuxt.config.ts:

export default defineNuxtConfig({
  plugins: [
    { src: '~/plugins/qrcode-vue3', ssr: false, mode: 'client' },
  ],
  ...
})

While my plugins/qrcode-vue3.ts looks like this:

import QRCodeVue3 from "qrcode-vue3";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component("QRCodeVue3", QRCodeVue3);
})

It works for me. I'm guessing it does not work with SSR, but it's good enough for me. (stole solution from here)

Katie-Adams commented 1 year ago

I added the following to nuxt.config.ts:

export default defineNuxtConfig({
  plugins: [
    { src: '~/plugins/qrcode-vue3', ssr: false, mode: 'client' },
  ],
  ...
})

While my plugins/qrcode-vue3.ts looks like this:

import QRCodeVue3 from "qrcode-vue3";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component("QRCodeVue3", QRCodeVue3);
})

It works for me. I'm guessing it does not work with SSR, but it's good enough for me. (stole solution from here)

This looks promising! I'll try and give it a go when I can, thanks :)

KyleSmith0905 commented 1 year ago

I noticed it gives a warning. Don't know how to remove it :/

But it does work