vue-js-modal and nuxt SSR

Created on 14 May 2020  路  4Comments  路  Source: euvl/vue-js-modal

Problem:

I get a "window is not defined" error when using this plugin in Nuxt.

Version:

Nuxt: 2.12.2
Vue-js-modal: 2.0.0-rc.3

Example & screenshots:

Screenshot 2020-05-14 at 12 55 26

The content of my 'vue-js-modal.js' in ~/plugins

import Vue from 'vue'
import VModal from 'vue-js-modal/dist/ssr.index'
import 'vue-js-modal/dist/styles.css'

Vue.use(VModal)

Most helpful comment

the readme states that ssr is supported but it's not working, ssr: false is just a workaround. Also it still gives an error:

  • e._ssrNode is not a function

imports should be changed to:

import Vue from 'vue'
import VModal from 'vue-js-modal'
import 'vue-js-modal/dist/styles.css'

Vue.use(VModal)

All 4 comments

I don't know your needs, but you can turn off the plugin in SSR-mode (because "window" doesn't exist on server without any workarounds).

I use the plugin in this way in nuxt.config.js:

plugins: [
  { src: '@/plugins/vue-js-modal', ssr: false }
],

I have same situation...

vue-js-modal also supported SSR mode, so it could be used without problems until now.

However, the version of nuxt is 2.12.2, and when developing in SSR mode, I also got "window is not defined"...

the readme states that ssr is supported but it's not working, ssr: false is just a workaround. Also it still gives an error:

  • e._ssrNode is not a function

imports should be changed to:

import Vue from 'vue'
import VModal from 'vue-js-modal'
import 'vue-js-modal/dist/styles.css'

Vue.use(VModal)

yo agregue { src: '~/plugins/vue-js-modal', mode: 'client' } y me funciona todo bien

Was this page helpful?
0 / 5 - 0 ratings

Related issues

at0g picture at0g  路  3Comments

ptilli picture ptilli  路  3Comments

chris-rowe picture chris-rowe  路  4Comments

outOFFspace picture outOFFspace  路  4Comments

uptownhr picture uptownhr  路  4Comments