I have imported an npm package to my Deno project. And in this package's code, there is a condition:
if (typeof window === 'undefined') {
throw new Error('Error initializing the sdk: window is undefined');
}
Program throws "window is undefined" error at this condition above.
I am able to access window object in my Deno project. Also, when I add a breakpoint to condition line in the cache folder files, I can access to window object from debug console as well.
It would be great if someone help me resolve this problem to get my program working with the npm package that uses window object.
Thanks in advance.
NPM packages gets the Node global object. And the Deno code gets the Deno’s global object. That’s why window is not present in the NPM package’s code.
So, to be able to still use the desired 3rd party module. I forked the module and made it Deno compatible. Afterwards, imported it into Deno project.