ReferenceError: window is not defined
HongYangWitness opened this issue · comments
Property window by default doesn't exist in a Node.js server but only in a browser client environment:
https://developer.Mozilla.org/en-US/docs/Web/API/Window/window
For client/server compatibility window needs to be replaced by globalThis:
https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
Even doing so, ccapture.js is a client library to capture a browser canvas element, which don't exist in a server environment by default.
Also, ccapture.js is distributed as a vanilla JS script file named "CCapture.all.min.js".
We can't use keyword import
on a browser context b/c "CCapture.all.min.js" isn't a module script file:
https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
I see. So this means it doesn't work with fabric.js canvas that using the node-canvas when it runs on node.js server, right? Thank you!