Skip to content

Conversation

@rdeshpande
Copy link

hey, just added a quick bugfix to check that module is defined - using this lib in a browser was throwing an error.

Check that "module" is defined before
trying to set exports (only works in node.js)
@mjb2010
Copy link
Contributor

mjb2010 commented Dec 14, 2011

I prefer to idiot-proof it, in case module is something like null:

try { module.exports = URI; } catch(ex) {}

...but maybe that's overkill?

@rdeshpande
Copy link
Author

Sure, that should work, but in node it seems to be okay either way?

foo
ReferenceError: foo is not defined
at [object Context]:1:1
at Interface. (repl.js:171:22)
at Interface.emit (events.js:64:17)
at Interface._onLine (readline.js:153:10)
at Interface._line (readline.js:408:8)
at Interface._ttyWrite (readline.js:585:14)
at ReadStream. (readline.js:73:12)
at ReadStream.emit (events.js:81:20)
at ReadStream._emitKey (tty_posix.js:307:10)
at ReadStream.onData (tty_posix.js:70:12)
typeof(foo)
'undefined'

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

Successfully merging this pull request may close these issues.

2 participants