GoJS for NodeJS Server (server-side)

I have a node server which uses a package that includes the GoJS libary.

After starting the server I got a error message window is not defined. This seems logical because GoJS needs a browser environment which NodeJS doesn’t provide.

So I added this package: GitHub - lukechilds/browser-env: Simulates a global browser environment using jsdom
This simulates a browser environment with the “window” object and other stuff.

However, it still doesn’t work. Now I get the error message right after startup:
Cannot set property 'fillStyle' of null

Is there any hint for solving this problem? I’m also completely open to other methods running GoJS on a NodeJS server.

I hope Server-Side Images with GoJS -- Northwoods Software provides a solution for you.

Thanks for your reply.

After some deeper investigation it turns out that browser-env does not provide support for the <canvas> element. So I used GitHub - node-gfx/node-canvas-prebuilt: Repo used to build binaries for node-canvas on CI and now everything is working fine.

Thanks for mentioning what you ended up using.