Can SVG images be produced server-side in a domless environment?

In this document I see how one can use nodejs directly and run GoJS in a domless environment:

The sample works fine as it is.

However, when I try to use myDiagram.makeImageData I obtain null.
An myDiagram.makeSvg raises TypeError: Cannot read properties of undefined (reading 'createElementNS')

This is the code that I added to the sample:

myDiagram.addDiagramListener('InitialLayoutCompleted', () => {
   console.log(myDiagram.model.toJson())

   const img = myDiagram.makeImageData({
       scale: 1,
       background: 'white',
       type: 'image/png',
       maxSize: new go.Size(400, 400),
       size: new go.Size(100,100)
   });
   console.log(img)
   const svg = myDiagram.makeSvg({
       scale: 1,
       // maxSize: new go.Size(400, 400),
       background: 'white',
       size: new go.Size(100,100)
   });
   console.log(svg)

}
);

It should be possible only if you have a package that fully mocks the DOM.

You best bet for server-side SVG is probably using puppeteer, or some other headless browser. See here: Server-Side Images | GoJS