Skip to content

node.js > ReferenceError: eoParse is not defined #4

@ubarbaxor

Description

@ubarbaxor

ReferenceError: window is not defined in Node.js

/Users/ubarbaxor/code/imagery-watcher/node_modules/libcoverage/src/parse.js:12
if (typeof window.DOMParser != "undefined") {
^

ReferenceError: window is not defined
    at Object.<anonymous> (/Users/ubarbaxor/code/imagery-watcher/node_modules/libcoverage/src/parse.js:12:1)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ubarbaxor/code/imagery-watcher/src/index.js:98:21)
    at Module._compile (module.js:624:30)

I've been checking in src/parse.js:12 there's something in the taste of :

if (typeof window.DOMParser != "undefined") { ... }
else if (typeof window.ActiveXObject != "undefined" &&
        new window.ActiveXObject("Microsoft.XMLDOM")) { ... }

This causes ReferenceError: window is not defined in node.js.

A simple solution would be to wrap the whole block in something in the taste of :

if (typeof window != "undefined") { ... }

I'm not sure this lib is meant to be usable in node, currently trying it to integrate DigitalGlobe API, so I had to fork and fix this myself.

I'm willing to issue a PR in case this issue can be addressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions