Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator is not Defined error #59

Closed
DZKeeper opened this issue Oct 8, 2019 · 1 comment
Closed

Navigator is not Defined error #59

DZKeeper opened this issue Oct 8, 2019 · 1 comment

Comments

@DZKeeper
Copy link

DZKeeper commented Oct 8, 2019

I am getting this error:

/usr/local/lib/node_modules/box-js/node_modules/vm2/lib/main.js:297
			throw this._internal.Decontextify.value(e);
			^
ReferenceError: navigator is not defined
    at vm.js:111:17
    at vm.js:143:6
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at VM.run (/usr/local/lib/node_modules/box-js/node_modules/vm2/lib/main.js:291:64)
    at Object.<anonymous> (/usr/local/lib/node_modules/box-js/analyze.js:442:5)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

And I am wondering if this is just because navigator is not defined as a value or ?

@CapacitorSet
Copy link
Owner

this is just because navigator is not defined as a value or ?

Indeed, the script expects navigator to be implemented, but box-js does not do so.

You're likely trying to run a script that was meant to run in a browser, whereas box-js targets WScript (which does not implement navigator either). With that in mind, you can try a simple patch in patch.js that exposes the properties your script might be interested in (eg. navigator = {appName: "Netscape", appVersion: "5.0 (Windows)"}), or something more complex with Proxy objects to see what the script is trying to read (there are many such objects in the codebase).

I won't be working on box-js for a good while, and especially not in the direction of targeting browser emulation, so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants