Nuxt Support? ReferenceError: window is not defined
See original GitHub issueI’d love to use TradingVue in a Nuxt Universal App. I tried getting the simple example to work in Nuxt 2.6.2, but just the import declaration causes the ReferenceError: window is not defined.
I created a simple example for demonstration / debugging purposes: nuxt-trading-vue
Just: $ npx create-nuxt-app nuxt-trading-vue $ yarn add trading-vue-js
And added the example code. Error is:
ReferenceError window is not defined.
node_modules/trading-vue-js/dist/trading-vue.js:17
define([], factory);
else if(typeof exports === 'object')
exports["TradingVueJs"] = factory();
else
root["TradingVueJs"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
Any ideas?
Issue Analytics
- State:
- Created 4 years ago
- Comments:12
Top Results From Across the Web
vue.js - “window is not defined” in Nuxt.js - Stack Overflow
The Window is not defined error results from nodejs server side scripts not recognising the window object which is native to browsers only....
Read more >ReferenceError: window is not defined · Issue #315 · nuxt/nuxt.js
I am using an add-on. I have read the headlines of those who have encountered this error. But I could not produce a...
Read more >Nuxt: window is not defined - Michael Whibley Blog
I came across an issue today when I was trying to use a 3rd party plugin vue2-scrollspy; I was continually getting “window is...
Read more >[ssr] window is not defined. Problem with vue-perfect-scroll
Hi, We've updated Perfect Scrollbar in the latest MDB Vue version 5.3.0. and I hope this problem will not occur anymore. Please let...
Read more >Creating Server-side Rendered Vue.js Apps Using Nuxt.js
The solution to this is clever: Have a version of the framework/library on the server that can build a ready-to-display page. Then send...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Mike-Kharkov following the nuxtjs docs, I did this:
trading-vue.client.jsfile in thepluginsfolder with this content:nuxt.config.js=>plugins: ['~/plugins/trading-vue.client.js'],Hope this helps – of course, this only renders on the client then, where the
windowissue should be solved automatically since unlike on the server side, the client actually haswindowdefined 😃@csabaxyz This solves your issue (DataCube was needed) https://github.com/tvjsx/trading-vue-nuxt
The remaining q is why all the injections are initially
undefined. Maybe some Nuxt-pro can tell us.