In my server.js, I need to check if one variable is true or not in my global.js (with an if statement), but later in that file I have window being used, and window is not defined in server files. This means that I can not require the whole file like so:
var global = require('../client/js/global');
But I would like to do something like this:
require thisSpecificVariable from ('../client/js/global');
There is something called import that imports a specific variable, but is not supported in node 8.
So just to clarify one more time, here is what I am trying to do:
if (this is true) {
call this function
}
But I am getting an error saying: "Reference Error: window is not defined at bla bla, at bla bla, at bla bla, and etc." Most of these places start with module.
My global.js looks like this (small bit of it as an example):
module.exports = {
freeMove: true,
cashing: false,
gameStarted: false,
chatHidden: false,
// Canvas
screenWidth: window.innerWidth,
screenHeight: window.innerHeight,
}
Is it possible to reference one specific variable or ignore the ones that include window? And how do I do it?