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.

Nuxt Support? ReferenceError: window is not defined

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:12

github_iconTop GitHub Comments

4reactions
HerrBertlingcommented, Jul 8, 2020

@Mike-Kharkov following the nuxtjs docs, I did this:

  • Install the package, of course.
  • Create trading-vue.client.js file in the plugins folder with this content:
import Vue from 'vue'
import TradingVue from 'trading-vue-js'

Vue.use(TradingVue)
  • Add the plugin within nuxt.config.js => plugins: ['~/plugins/trading-vue.client.js'],
  • Copy&Paste the “Minimal working example” into the page you want to use the chart
  • See chart

image

  • ???
  • Profit 💸 💸 💸 😝

Hope this helps – of course, this only renders on the client then, where the window issue should be solved automatically since unlike on the server side, the client actually has window defined 😃

1reaction
C451commented, Nov 15, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

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