hope someone can help me with this error.
I’m using angular 17, and when installing Editorjs it shows an error sayin “Window is not defined”
2:40:55 PM [vite] Error when evaluating SSR module /main.server.mjs:
|- ReferenceError: window is not defined
at eval (/.../Documents/GitHub/ErrorTest/node_modules/@editorjs/editorjs/dist/editorjs.mjs:44:1)
at async instantiateModule (file:///.../Documents/GitHub/ErrorTest/node_modules/vite/dist/node/chunks/dep-k5wXcrSr.js:54897:9)
2:40:55 PM [vite] Internal server error: window is not defined
at eval (.../Documents/GitHub/ErrorTest/node_modules/@editorjs/editorjs/dist/editorjs.mjs:44:1)
at async instantiateModule (file:///.../Documents/GitHub/ErrorTest/node_modules/vite/dist/node/chunks/dep-k5wXcrSr.js:54897:9)
2:40:55 PM [vite] Internal server error: window is not defined
at eval (.../Documents/GitHub/ErrorTest/node_modules/@editorjs/editorjs/dist/editorjs.mjs:44:1)
at async instantiateModule (file:///.../Documents/GitHub/ErrorTest/node_modules/vite/dist/node/chunks/dep-k5wXcrSr.js:54897:9) (x2)
I published a repository to replicate the error.
Thanks in advance
I have already tryed to encapsulate the EditorJs into a conditional.
if (isPlatformBrowser(this.platformId)) {
this.editor = new EditorJS({
holderId: 'editor-js',
});
}
Also
if (typeof window !== "undefined") {
this.editor = new EditorJS({
holderId: 'editor-js',
});
}