arboleya / electrify

Package your Meteor apps with Electron, and butter
MIT License
247 stars 52 forks source link

Electrify on Windows Fails on Meteor Boot unless NPM Install Manually #11

Closed msolters closed 8 years ago

msolters commented 9 years ago

Adding arboleya:electrify to Meteor projects causes them to crash on boot. This happens in both Windows 8.1 and Windows 10 (separate computers). This happens with pre-existing projects as well as the leaderboard example:


=> Started proxy.
=> Started MongoDB.
I20150914-18:49:10.001(-4)? electrify:  installing electrified dependencies
I20150914-18:49:10.297(-4)? electrify:  launching electron
=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

W20150914-18:49:10.328(-4)? (STDERR)
W20150914-18:49:10.328(-4)? (STDERR) module.js:340
W20150914-18:49:10.328(-4)? (STDERR)     throw err;
W20150914-18:49:10.328(-4)? (STDERR)           ^
W20150914-18:49:10.328(-4)? (STDERR) Error: Cannot find module 'C:\Users\Mark Solters\Documents\GitHub\leaderboard\.elec
trify\node_modules\electron-prebuilt\cli.js'
W20150914-18:49:10.328(-4)? (STDERR)     at Function.Module._resolveFilename (module.js:338:15)
W20150914-18:49:10.328(-4)? (STDERR)     at Function.Module._load (module.js:280:25)
W20150914-18:49:10.328(-4)? (STDERR)     at Function.Module.runMain (module.js:497:10)
W20150914-18:49:10.328(-4)? (STDERR)     at startup (node.js:119:16)
W20150914-18:49:10.328(-4)? (STDERR)     at node.js:929:3

But, if I cd .\.electrify and then manually install NPM dependencies with npm install, everything works. This took me a while to figure out by trial and error. I'm not sure why this is not actually being done when it says "Installing electrified dependencies."

arboleya commented 9 years ago

It should be related to my last patch. Weird enough, for some reason it worked fine here.

Which version of Windows are you using?

arboleya commented 9 years ago

Btw, the patch in question solved in issue #8 apparently have worked and should not raise the error you've mentioned.

  1. Which version of Windows are you using?
  2. Did you test it with a plain leaderboard example? Just so I can replicate it here.
msolters commented 9 years ago
  1. Both Windows 8.1 and 10.
  2. Yes, I created the leaderboard example from the meteor cli, cd'd in and immediately added the electrify package. I did not alter any code.
arboleya commented 9 years ago

I don't have any windows 8.1 or 10 machine, but I went through the whole test again in Win7 (32bits & 64bits), and it's working fine -- output below.

Curious that Electrify just enters the .electrified folder and executes a simple npm install. I was thinking that your problem may be some kinda of network permissions issue, like if the Electrify couldn't install things that needs to be downloaded, as the npm packages.

Makes any sense?

win7-64@WIN7-64-PC C:\Users\win7-64\Desktop\tmp
> meteor create --example leaderboard && cd leaderboard
leaderboard: created.

To run your new app:
  cd leaderboard
  meteor

win7-64@WIN7-64-PC C:\Users\win7-64\Desktop\tmp\leaderboard
> meteor add arboleya:electrify && meteor

Changes to your project's package version selections:
arboleya:electrify  added, version 1.2.2

arboleya:electrify: Package your Meteor apps with Electron, and butter.
[[[[[ C:\Users\win7-64\Desktop\tmp\leaderboard ]]]]]

=> Started proxy.
=> Started MongoDB.
I20150915-09:49:31.266(-7)? electrify:  setting up folders
I20150915-09:49:47.134(-7)? electrify:  copying template files
I20150915-09:49:47.134(-7)? electrify:  installing electrified dependencies
I20150915-09:49:47.134(-7)? electrify:  launching electron
=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

[756:0915/094941:INFO:renderer_main.cc(200)] Renderer process started
msolters commented 9 years ago

I get the same errors if I run these commands (i.e. npm install -g electrify and/or meteor) from a terminal that I've opened as administrator. Not sure what other permission elevation one can do in a windows environment?

bradzo commented 9 years ago

hi Mark @msolters

I had this same problem on a brand new installation of Windows 7 under VirtualBox. I got the same error you did.

Maybe Anderson @arboleya had already installed node and npm using the installer from the official nodejs.org site? (If you still can't install it manually and get it to run)

So I went there and downloaded the *.msi file, and installed it.

I still had my Meteor project open in a command window, and tried to run Meteor again and see if I could get past the error messages. No luck.

However, after closing the command prompt window and re-opening it, I see that my path now included the npm folder.

I re-ran my Meteor project, and all went according to plan! Success!

So for anyone else looking for a resolution, just install the relevant package (architecture - I was prompted to download the 64-bit version) from nodejs.org and you should be good to go.

Thanks to Anderson @arboleya for all your work on this - amazing effort! I can now produce apps for Web, iOS, Android, and with your Electrify package, apps for Mac Desktop, *nix Desktop and now, Win Desktop.

Meteor + Electrify FTW.

msolters commented 9 years ago

@bradzo Are you saying all you did was to install NodeJS & NPM?

All machines that this problem occurs on -- and that now includes at least one instance of Yosemite -- have both node and npm as valid commands in their path when Meteor is run. I've tried both v4.0 (from the NodeJS.org site) and v0.10.36 (the version that Meteor bundles with its own installations).

The presence of these commands is not the problem I am seeing. The problem is that electron-prebuilt is not being properly installed by the electrify package.

bradzo commented 9 years ago

Hi Mark @msolters

Essentially, yes. That's all I did. Just downloaded the .msi installer from the nodejs.org site and ran it.

Also, on Yosemite for me, the same Meteor app ran fine with Electrify - I didn't do anything extra, so I really can't help you there either... :(

arboleya commented 9 years ago

Hello everyone, the question is that Electrify itself doesn't use the user installed version no NodeJS or NPM. The way it install the dependencies is through the node/npm binaries that are distributed along Meteor itself.

// https://github.com/arboleya/electrify/blob/master/index.meteor.js#L273-L275
  log('installing electrified dependencies');
  var cmd = ['cd', _ELECTRIFIED, '&&', _METEOR_NODE, _METEOR_NPM, 'install'];
  exec(cmd.join(' '), _SILENT_EXECS);

However the current error-reporting system is crap, the _SILENT_EXECS silent any error when it's not in dev mode. And enabling DEV mode requires lots of other settings to work properly.

Good news is I'm working on a new version which will be more stable and specially more easy about chasing cross-platform bugs. Stay tuned, I'll update here when it's available.

msolters commented 9 years ago

I totally understand, Meteor is still hanging back with some older exec() support. I wish they'd just move up at least enough to use child_process.execSync! In general, assuming Node modules will just run fine is never a safe supposition, so I appreciate the struggle.

Still, this explains why manually running npm install inside .electrify works -- even though it grabs the dependencies via whatever the user's system Node and NPM versions are, it does grab the missing files that constitute electron-prebuilt, and those file system resources are shared between Meteor's Node and whatever binary the user uses.

arboleya commented 8 years ago

Hello @msolters @bradzo

I've just released a complete revamp version of the project, now it has tests and I'm confident it's way more stable than before.

Can you please update and report back if you still are facing the problem you've mentioned?

Some notes on upgrading: https://github.com/arboleya/electrify#upgrading

Thanks in advance.

msolters commented 8 years ago

Awesome!

I tried it out on Windows 10. Still no luck. Now when I start my app up:

I20151003-03:14:25.851(-4)? INFO  electrify:app:  packaging app
I20151003-03:14:30.507(-4)? INFO  electrify:scaffold:  ensuring basic structure
I20151003-03:14:30.507(-4)? INFO  electrify:electron:  ensuring electron dependencies
I20151003-03:14:30.507(-4)? INFO  electrify:electron:  electron-prebuilt installation seems ok, moving on
I20151003-03:14:30.507(-4)? INFO  electrify:electron:  electron-packager installation seems ok, moving on
I20151003-03:14:30.507(-4)? INFO  electrify:plugins:  acquire
=> Exited with code: 8
W20151003-03:14:30.502(-4)? (STDERR)
W20151003-03:14:30.502(-4)? (STDERR) C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboleya_electrify\1.3.4\npm\n
ode_modules\electrify\lib\app.js:103
W20151003-03:14:30.502(-4)? (STDERR)   var pkg_version = require(pkg_path).dependencies.electrify;
W20151003-03:14:30.503(-4)? (STDERR)                                                   ^
W20151003-03:14:30.503(-4)? (STDERR) TypeError: Cannot read property 'electrify' of undefined
W20151003-03:14:30.503(-4)? (STDERR)     at App.ensure_deps (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arbole
ya_electrify\1.3.4\npm\node_modules\electrify\lib\app.js:103:51)
W20151003-03:14:30.503(-4)? (STDERR)     at Electrify.waterfal (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arb
oleya_electrify\1.3.4\npm\node_modules\electrify\lib\index.js:45:13)
W20151003-03:14:30.503(-4)? (STDERR)     at C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboleya_electrify\1.3.
4\npm\node_modules\electrify\lib\index.js:47:12
W20151003-03:14:30.503(-4)? (STDERR)     at C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboleya_electrify\1.3.
4\npm\node_modules\electrify\node_modules\lodash\index.js:7305:23
W20151003-03:14:30.503(-4)? (STDERR)     at NodeJS.acquire (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboley
a_electrify\1.3.4\npm\node_modules\electrify\lib\plugins\nodejs.js:31:3)
W20151003-03:14:30.504(-4)? (STDERR)     at C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboleya_electrify\1.3.
4\npm\node_modules\electrify\lib\plugins.js:28:12
W20151003-03:14:30.504(-4)? (STDERR)     at arrayEach (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arboleya_ele
ctrify\1.3.4\npm\node_modules\electrify\node_modules\lodash\index.js:1289:13)
W20151003-03:14:30.504(-4)? (STDERR)     at Function.<anonymous> (C:\Users\Mark Solters\AppData\Local\.meteor\packages\a
rboleya_electrify\1.3.4\npm\node_modules\electrify\node_modules\lodash\index.js:3345:13)
W20151003-03:14:30.504(-4)? (STDERR)     at Plugins.acquire (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arbole
ya_electrify\1.3.4\npm\node_modules\electrify\lib\plugins.js:27:5)
W20151003-03:14:30.504(-4)? (STDERR)     at Electrify.waterfal (C:\Users\Mark Solters\AppData\Local\.meteor\packages\arb
oleya_electrify\1.3.4\npm\node_modules\electrify\lib\index.js:45:13)

The server will recover from these errors, and eventually server the Meteor app. But the Electron app will never start up. In addition, I get the exact same STDERR output as above when I issue Electrify.app.package() from meteor shell.

msolters commented 8 years ago

Ah! I have found the solution. I just deleted all of my old .electrify, and then removed and re-added the arboleya:electrify.

Restarting the Meteor server with these fresh conditions, the new package proceeds to work as expected on Windows 10!

arboleya commented 8 years ago

Glad to know :)