A starter project demonstrating how to spawn an Express app from Electron, node JS best practices and angular on front
Express App:
- Clone the code repository.
- Open terminal to code repository.
- Make sure a copy of
Node.exe
andNode.lib
are copied to the root of the code repository. - Run
npm install
. (See Dependencies above) - Change directories to the express-app folder and run
npm install
. - Change directories back to the root of the code repository.
- Run
npm start
to start the application.
If you would like to package this using electron-packager
you'll need to
make the following change:
In index.html (line ~65):
app = require('electron').remote.app,
node = spawn(".\\node.exe", ["./express-app/bin/www"], { cwd: app.getAppPath() })
This makes sure the path to our local copy of node.exe
is correct when we run
electron to start the app.
That said, I'm assuming the platform is Windows. If other platforms are desirable additional changes are required.
Download standalone distribution of Node: 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:
Change line 65 in index.html to the following:
node = spawn("./node", ["./express-app/bin/www"], { cwd: process.cwd() })
Then you can run it like this:
./node start-electron.js &
Or edit the scripts section in 'package.json' and change it to:
"scripts": {
"start": "./node start-electron.js"
},
Then run
npm start