0

How do I add vConsole.js to Nuxt?

// debugging
import VConsole from "vconsole";
const vConsole = new VConsole();

This causes the error window is not defined

I am stuck... any help very much appreciated.

Thanks!

2 Answers 2

1

window isn’t defined on the server-side. You need to use vConsole as a client side plugin.

plugins/vConsole.client.js

import VConsole from 'vconsole' 
Vue.use(VConsole)

Don’t forget to add it to your nuxt.config.js

plugins: { src: '~/plugins/vConsole.client.js' }
1
  • thank you!!!!! ` import Vue from 'vue'; import vConsole from 'vconsole'; const vc = new vConsole(); Vue.use(vc); `
    – MissJulie
    Dec 2, 2020 at 23:00
0
import Vue from 'vue';
import vConsole from 'vconsole';

const vconsole = new vConsole();
Vue.use(vconsole);

this did the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.