question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

document is not defined in Nuxt

See original GitHub issue

I use vue-qr-reader with<client-only> tag in Nuxt project, but I have an error: document is not defined and infinity loading page

To Reproduce

<template>
  <client-only>
     <QrcodeStream />
  </client-only>
</template>

<script>
import { QrcodeStream } from 'vue-qrcode-reader'
...

Desktop

  • OS: ubuntu 16.04
  • Browser: chrome 79
  • Version “vue-qrcode-reader”: “^2.1.1”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
radislawcommented, Feb 3, 2020

I created plugin file for use VueQrcodeReader globally

import Vue from 'vue'
import VueQrcodeReader from 'vue-qrcode-reader'

Vue.use(VueQrcodeReader)

Then added it in nuxt.config.js with mode: ‘client’

 plugins: [
    { src: '@/plugins/qrCodeReader.js', mode: 'client' }
]

And just use it:

<qrcode-stream @decode="onDecode" />

I think this should be added to the documentation.

1reaction
delruebacommented, Jan 31, 2020

Wrap the QrcodeStream in your own component and then import your component like this

components: { scanner: () => import('@/components/client-only/Scanner') }

<client-only>
  <scanner />
</client-only>
Read more comments on GitHub >

github_iconTop Results From Across the Web

"document is not defined" in Nuxt.js - Stack Overflow
So Nuxt tried to renderer from server-side, but from Node.js window.document doesn't exist, then you have an error. nb: window.document is only ...
Read more >
document is not defined with nuxt · Issue #764 - GitHub
I follow the instruction in readme and when I try to access my app I got the error: document is not defined.
Read more >
[Solved]-"document is not defined" in Nuxt.js-Vue.js
It's a common error when you start a Nuxt project ;-). The Choices.js lib is available only for client-side! So Nuxt tried to...
Read more >
Server Side Rendering - Nuxt
Server-side rendering (SSR), is the ability of an application to contribute by displaying the web-page on the server instead of rendering it in...
Read more >
Javascript – “document is not defined” in Nuxt.js - iTecNote
The Choices.js lib is available only for client-side! So Nuxt tried to renderer from server-side, but from Node.js window.document doesn't exist, then you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found