Using GoJS with NodeJS - "ReferenceError: window is not defined" in file go-debug.js:2055:325

I was trying to use GoJS with NodeJS in a simple program. I’m using NodeJS v4 on Win7. I’m testing on Firefox.
I’m also using Express and Jade with NodeJS
I didn’t modify the default files like app.js after creating a project in NodeJS. The following are the

index.jade content

extends layout
block content
  h1= title
  p Welcome to #{title}
  #myDiagramDiv(style='width:400px; height:150px; background-color: #DAE4E4;')

index.js content

var express = require('express');
var router = express.Router();

var go;

/* GET home page. */
router.get('/', function(req, res, next) {
    go = require("../node_modules/gojs/release/go-debug.js"); 
    var $ = go.GraphObject.make;
    var myDiagram =
    $(go.Diagram, "myDiagramDiv",
        initialContentAlignment: go.Spot.Center, // center Diagram contents
        "undoManager.isEnabled": true // enable Ctrl-Z to undo and Ctrl-Y to redo

    var myModel = $(go.Model);
    // in our model data, each node is represented by a JavaScript object:
    myModel.nodeDataArray = [
    { key: "Alpha" },
    { key: "Beta" },
    { key: "Gamma" }
    myDiagram.model = myModel;

    res.render('index', { title: 'Express' });
module.exports = router;

I’m getting on the browser the following error

window is not defined
ReferenceError: window is not defined
at Object. (C:\JavaScript\IQTestGenerator\graphTest\node_modules\gojs\release\go-debug.js:2055:325)
at Module._compile (module.js:409:26)
at Object.Module._extensions…js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at C:\JavaScript\IQTestGenerator\graphTest\routes\index.js:14:10
at Layer.handle [as handle_request] (C:\JavaScript\IQTestGenerator\graphTest\node_modules\express\lib\router\layer.js:95:5)
at next (C:\JavaScript\IQTestGenerator\graphTest\node_modules\express\lib\router\route.js:131:13)

I’m not familiar with Express or Jade, but it seems to me that you want to be manipulating a GoJS Diagram and Model on the client – not on the server.

If you really want to be using GoJS on the server, you could look at the PhantomJS sample that is in the “projects” subdirectory.

Thanks Walter for your reply.
I want to create an online app that allows the user to draw shapes, graphs, … save them, retrieve, edit, etc, …
I’m a beginner in NodeJS and not familiar with PhantomJS.
My update for index.js file was based on your reply in this post GoJS for desktop applications?

Can you please direct me to examples on how to use GoJS with NodeJS? Thanks

If one is creating a web app, one should not be following instructions for creating a desktop app.

All of the samples and extensions that you can see at are basically single-page web apps. However none of them depend on anything but the web server serving static pages, so there is no state that any of the samples can save on our server.

I suggest that you learn about how to create simple interactive web apps using NodeJS. Once you know that, you can insert a GoJS diagram into your page that just shows some data. Then you can have your app start to save diagram state in your server. How you do those things depend on the framework(s) that you have chosen, if any, both for the client side and for the server side.