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

Uncaught module 'emitter' not found #95

Closed
lwille opened this issue Jun 6, 2012 · 17 comments
Closed

Uncaught module 'emitter' not found #95

lwille opened this issue Jun 6, 2012 · 17 comments

Comments

@lwille
Copy link

lwille commented Jun 6, 2012

Shouldn't it be "events"?

I'm using superagent in the browser with stitch, cf my comment on 8acb989.

@tj
Copy link
Contributor

tj commented Jun 6, 2012

i have a different module for the client called "emitter" for something I'm working on, but maybe we can add support for "events" since browserify will use this too

@lwille
Copy link
Author

lwille commented Jun 6, 2012

Okay, I think I messed up something. You're checking for an "exports" variable which should only exist when running on node. But stitch is supplying module, exports and all that stuff in the client.

Also, the events.js is only working when prepended to superagent.js - not when required via the CommonJS interface (it's missing a module.exports). I'll make a pull request if you like.

@tj
Copy link
Contributor

tj commented Jun 6, 2012

well the thing is that it's detecting exports for a thing I have in the works, which just happens to use "emitter" instead of node's one because it has a slightly different API and removes the require('events').EventEmitter fluff. We would need a way to tell which environment this thing is in even with both module and exports is present

@clux
Copy link

clux commented Oct 15, 2012

Yeah, it would be nice to be able to use this with browserify as well.

One alternative I can see is to set a different main with browserify, i.e. specify "browserify" : "browserifyEntry.js" in package.json. Then move the eventEmitter stuff to the two entry points, and injected the right one in those. This should make the packaged code slimmer as well.

@tomasdev
Copy link

👍 having this issue while using superagent inside node-webkit (and I don't know why it doesn't find EventEmitter - @rogerwang maybe?)

@tomasdev
Copy link

I've just found out it's because of superagent index.js file:

if (typeof window != 'undefined') {
  module.exports = require('./lib/superagent');
} else if (process.env.SUPERAGENT_COV) {
  module.exports = require('./lib-cov/node');
} else {
  module.exports = require('./lib/node');
}

:| I don't know if this is node-webkit responsibility or superagent's.

@jduncanator
Copy link

@tomasdev It's super agents. However things could get complicated and messy when detecting node-webkit over browsers. I'd suggest something like:

if((typeof process != 'undefined' && process.versions['node-webkit']))
    // This is node-webkit!

@gjohnson
Copy link
Contributor

@tomasdev thats odd... superagent supports the browser and node, not sure what node-webkit could be doing to mess up the node or webkit side of things.

@gjohnson
Copy link
Contributor

Closing this for now because people are using superagent fine in the browser via the download file, component or even browserify.

@tomasdev I am certain that's going to be node-webkit's problem, but feel free to open a newer issue if you feel differently.

@jduncanator
Copy link

@gjohnson The issue is that node-webkit exposes a global window variable which causes superagent to think its running in a browser, even tho node-webkit supports the full Node.js APIs.

@tj
Copy link
Contributor

tj commented Mar 13, 2014

gah haha fragmentationnnn..

@rogerwang
Copy link

@tomasdev I'm considering removing the window reference from Node context in node-webkit. I'm not sure whether other developers would need it.

@jduncanator
Copy link

@rogerwang What exactly do you mean?

@rogerwang
Copy link

I mean the global window variable which causes superagent to think its running in a browser. Some other JS libraries use this way too. In order not to confuse them I'm thinking to remove it from the Node context of node-webkit, so JS libraries would run smoothly.

@jduncanator
Copy link

@rogerwang But would that not affect all the other applications built to use window? I'm not sure I understand what you mean by "Node Context"

@gjohnson
Copy link
Contributor

@rogerwang @jduncanator @tomasdev I am interested in this conversation, but for the sake of other watchers/maintainers on here, let's move this to a thread on node-webkit. Please paste the issue link. Thanks!

@rogerwang
Copy link

Please discuss here in future: nwjs/nw.js#1588

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

7 participants