score:1

Accepted answer

the reason why this is happening is because you are running ssr with nodejs and there is no window object, so you need a nodejs replacement.

i suggest installing domino

npm i --save-dev domino

then in your server.ts

const domino = require('domino');

const template = fs
  .readfilesync(path.join('dist/browser', 'index.html')) // or whereever your rendered index.html is
  .tostring();


const window = domino.createwindow(template);
(global as any).window = window;
(global as any).document = window.document;

Related Query

More Query from same tag