frankhale / electron-with-express

A simple app that demonstrates spawning an Express app from Electron
MIT License
662 stars 145 forks source link

how would you make this work on linux? #8

Closed mateo-io closed 7 years ago

mateo-io commented 7 years ago

Hello this is exactly what I want but I want to run it on linux and I'm kind of an electron noob.

Has anyone already done that or know what changes I need to do in order to get it working.

Thanks

frankhale commented 7 years ago

Nothing in the example should be OS specific, it should just work on Linux. What issues are you experiencing?

frankhale commented 7 years ago

At any rate I will test today on Linux to see if there are any issues

frankhale commented 7 years ago

Just upgraded all dependencies and ran on Windows, everything is fine. Will test Linux when I get back home this afternoon.

express-with-electron-screenshot

frankhale commented 7 years ago

Need to make sure you download the node executable and it's shared library for Linux and put them in the root of the cloned repository like the screenshot above. It uses it's own Node to spawn the Express app. Of course you can change this if you want it to use the system installed Node but the general idea is that it'd be nice to bring our own Node in case the machine doesn't already have it.

frankhale commented 7 years ago

Okay currently testing in Linux and yes I can see how my instructions will need to be modified for running in Linux. I'm hoping to have this updated today.

frankhale commented 7 years ago

Okay it's working with just a very minimal change which I'll document shortly

express-with-electron-linux-screenshot

frankhale commented 7 years ago

I'm assuming that npm install has been ran for both the root of the repository and in express-app to install all dependencies.

Just to clarify there is really no need to download a stand alone copy of Node unless you really want to. You can just use a regular install of node to spawn Express. Line 65 in index.html would need to be changed slightly to:

node = spawn("node", ["./express-app/bin/www"], { cwd: process.cwd() })

Otherwise if you prefer to do it like I do continue reading...

Downloading a standalone Linux build is slightly more annoying than the nicely statically linked Windows executables but just as easy to deal with.

So basically download Node (whatever build you want, I always use latest):

https://nodejs.org/dist/latest-v7.x/node-v7.10.0-linux-x64.tar.gz

Unpack it into the root of the cloned repository. Then create a symbolic link called 'node' at the same location.

ln -sf node-v7.10.0-linux-x64/bin/node node

Here is a screenshot of what it should look like:

express-with-electron-linux-folder-structure-screenshot

Change line 65 in index.html to the following:

node = spawn("./node", ["./express-app/bin/www"], { cwd: process.cwd() })

Then you can run it:

./node start-electron.js &
frankhale commented 7 years ago

README has been updated to reflect what was done here to run on Linux.

Thank you for asking this!

Closing via 87c5e7aa945ef1cd9d1c3eed1f1bd43dc11d5149

frankhale commented 7 years ago

@mateo-io you good with these instructions?