brzpegasus / ember-cli-nwjs

An addon for building desktop apps with Ember and NW.js
MIT License
125 stars 17 forks source link

nw.js refuses to start #48

Closed shripathee closed 8 years ago

shripathee commented 8 years ago

Getting these errors:

Error: Could not find module `fs` imported from `(require)`
Uncaught Error: Could not find module `ember-resolver` imported from `happyfox-web/app`

Ember CLI version: 2.2.0-beta.3 Ember version: 2.3.0-beta.3

brzpegasus commented 8 years ago

I'll take a look later tonight. Tied up with client work at the moment!

shripathee commented 8 years ago

Okay :)

brzpegasus commented 8 years ago

Everything is working with Ember CLI 1.13.13 and Ember 2.3.0-beta.3. So it's definitely an issue with the beta version of the CLI. Maybe something with the loader. I'll keep you posted.

brzpegasus commented 8 years ago

Ok, so the problem is because the new loader.js defines a variable called global, which overrides NW's own global. Joy!

// loader.js
var global = this;

(function() {
  // ...

  loader = {
    noConflict: function(aliases) {
      var oldName, newName;

      for (oldName in aliases) {
        if (aliases.hasOwnProperty(oldName)) {
          if (oldGlobals.hasOwnProperty(oldName)) {
            newName = aliases[oldName];

            global[newName] = global[oldName];
            global[oldName] = oldGlobals[oldName];
          }
        }
      }
    }
  };

I'm guessing we can rename global to _this or something that doesn't conflict in loader.js, but I'm not 100% sure. That's just from quickly looking over the file.

rwjblue commented 8 years ago

Great job tracking this down!

loader.js@3.6.1 is released with your fix...

brzpegasus commented 8 years ago

w00t!

shripathee commented 8 years ago

Updated loader.js to 3.6.1. nw is working now. Thanks guys :)