ReferenceError: 'navigator is not defined' in node-webkit #223

Closed
Soviut opened this Issue Jan 30, 2014 · 6 comments

Projects

None yet

2 participants

@Soviut
Soviut commented Jan 30, 2014

I tracked this down to here https://github.com/aws/aws-sdk-js/blob/master/lib/util.js#L40

Because node-webkit is using a browser to run code on the desktop, it confuses the isBrowser check.

It would be good if there was an explicit way of defining the environment.

@Soviut
Soviut commented Jan 30, 2014

I was able to deal with this by overriding the isBrowser function in the code that requires it and making it always return false:

var aws = require('aws-sdk');
aws.util.isBrowser = function() { return false; };

This feels hacky and prone to failure in the future, so some kind of explicit override would be nice.

@lsegal
Contributor
lsegal commented Mar 1, 2014

Can you provide more information about when you are getting this error? A stack trace would be helpful (printing err.stack).

@Soviut
Soviut commented Mar 1, 2014

node-webkit is a chrome-less webkit browser that lets you create desktop apps using html,css and js but with access to local node libraries and functions, so my angular app can list my file system using fs for example.

The problem is that because node-webkit acts as both a local app and a browser, it confuses the aws library, leading it to believe it's running in a browser when I want it to run as a local application. Because node-webkit is considered local, it has no navigator object defined, and the aws library, which thinks I'm in a browser, but with no navigator, throws a reference error.

@lsegal
Contributor
lsegal commented Mar 1, 2014

Can you provide the stack trace for this exception?

@Soviut
Soviut commented Mar 10, 2014

@lsegal For whatever reason, while reverting back to an older version of my code, I can't reproduce the issue anymore.

@lsegal
Contributor
lsegal commented Mar 10, 2014

I'm going to close this, then. If you find a way to provide steps to reproduce or an exception that is raised, feel free to re-open this or create a new issue. I'd be happy to look through and see what we could do about fixing it.

Glad you got it working, though.

@lsegal lsegal closed this Mar 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment