brzpegasus / ember-cli-nwjs

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

Unable to find modules #34

Closed alexlafroscia closed 9 years ago

alexlafroscia commented 9 years ago

For some reason, after running ember nw I am unable to see the site because some of my dependency's modules can't be found. I see an error like this:

Error: Could not find module route-recognizer Error: Could not find module ember-modal-dialog/initializers/add-modals-container imported from `qualaris-mantra/initializers/add-modals-container

But, as far as I can tell, the modules are being included in the build correctly. Here is a screenshot of the dev tools for the Node Webkit window:

screen_shot_2015-07-20_at_2_36_56_pm

The build works totally fine when using ember serve or ember build; it only is an issue when running ember nw.

Edit: I tried doing ember nw:package and that seems to work fine. It's just the server version that fails to find the files.

Edit 2: I tried ember nw:test and got a whole bunch of Cannot find module errors, and then also a bunch of failed tests that just said

not ok XXX NW.js (CI) - MISSING TEST

Ultimately, it looks like the correct number of tests were run, but that most of the real tests were "missing". All of the JSHint and JSCS tests were fine.

Edit 3: It seems to be related to the build environment. production is fine, development and test both seem broken.

brzpegasus commented 9 years ago

Let me try to reproduce this and get back to you.

alexlafroscia commented 9 years ago

Sure thing. If it's useful, I can try to distill my app down to just enough to get it to break and put that somewhere public.

brzpegasus commented 9 years ago

Just an update--there seems to be something weird going after upgrading to Ember 1.13.x. I took an existing app that ran well in 1.12, upgraded, and ember nw continues to work fine. However, ember nw:test now breaks with this error:

screen shot 2015-07-24 at 12 50 40 pm

It is using the correct require function to find the module, so that's not the issue. I know you're having problems with ember nw as well. Perhaps it is related. I'm still trying to figure out what's causing this.

brzpegasus commented 9 years ago

I figured out the testing issue. Ember 1.13.x does something different if it notices that it is running in Node, by looking for the global process object. This of course will break the app in NW:

screen shot 2015-07-24 at 3 17 46 pm

I'll push up a fix/release, and then you can see if that also solves the issue you're running into in your app.

alexlafroscia commented 9 years ago

Awesome! Thanks so much for digging into this :grinning:

brzpegasus commented 9 years ago

I believe this should be addressed by #38. The fix is available in the following versions:

I've finally renamed the project (node-webkit itself had been renamed to NW.js a while ago), but you should be able to verify whether the issue is still present on whichever version you'd like.

brzpegasus commented 9 years ago

I'll leave this open until you're able to confirm that it works.

alexlafroscia commented 9 years ago

Alright, well that got me part of the way there. I updated to ember-cli-nwjs@0.3.6 and checked ember nw, and the app booted just fine. However, ember nw:test still failed. Here is a Gist of the output, but the gist (pun somewhat intended) is that it ran the first three tests, followed by 895 occurrences of MISSING TEST.

brzpegasus commented 9 years ago

What about if you were to run the tests with ember nw:test --server? Do you get the same errors, and if so, if you open up the console in the browser, do you see any errors being thrown?

alexlafroscia commented 9 years ago

Alright, so I updated my Ember CLI version to the latest master for an unrelated reason, and am now seeing different behavior here. The same three tests run, but instead of erroring all those times, it just stops after those three. Not sure if the Ember CLI update was related to the change.

I tried ember nw:test --server and see basically the same thing that I see with ember nw:test; the three tests run, and then the NW window closes immediately so I don't have a change to get at the console.

brzpegasus commented 9 years ago

I absolutely want to get to the bottom of this! I just need to find a way to reproduce. How hard would it be for you to trim off any private code that you don't wish to expose and extract into a public repo that I can check out? If that doesn't work, then I'm open to doing a Screenhero or Hangout.

alexlafroscia commented 9 years ago

It might be sorta tough to strip out the private stuff; this is our main product so I'm not sure that's an option. Maybe we could schedule a hangout or something, or I could talk to my team about giving you pull access or something to check the code out yourself.

brzpegasus commented 9 years ago

The latter would be ideal, as figuring out what's causing the issue could take some time and having direct access to a repo that's displaying this behavior would be easier. But I can understand if that can't be done. Let me know what you'd rather do. DM me on the Ember Community slack if you want to do the hangout route and we can figure out the details. I'm there as @edeblois.

brzpegasus commented 9 years ago

Just wanted to capture here, for future reference, that this issue is likely due to the runner hitting the max buffer size when running exec. I'll see if I can get this working with require('child_process').spawn instead.

alexlafroscia commented 9 years ago

@brzpegasus are the things filling the buffer stuff that's trying to be logged, like the deprecation warnings? Our app triggers a ton of those due to the old Ember Data version we're stuck on.

brzpegasus commented 9 years ago

Yes, exactly. I was able to reproduce the issue by simply doing a mega console.log() in a loop from within my Ember app.

I have it working now with spawn. The only thing blocking me from pushing the updates is this one tiny thing left to figure out: For the ember nw:test --server mode, I have to modify the Testem launcher to run runner.js as opposed to running nw directly, because Testem will call nw using exec otherwise. So I need to get Testem to exec the runner, and let the runner spawn nw. This works, except for killing the NW.js child process when Testem terminates. Right now, if you hit "Q" to end Testem, you still have to Ctrl+C to exit nw.

But I'm close!

brzpegasus commented 9 years ago

Can you try with version 0.3.7 and see if that solves the problem on your end? I tested it with my sample app but would like to get your confirmation.

alexlafroscia commented 9 years ago

That seemed to do it! A few test are failing that weren't failing with ember test, but don't think that's related. Thank you so much!

brzpegasus commented 9 years ago

Awesome! Glad we got this figured out.