File structure clarification for combining web app in Electron


Hello! I just learned about Electron and I’m looking to place my Twitter Aggregator web app in Electron to run it as a desktop app. I’ve gone ahead and created a root folder with package.json, main.js and index.html files in it. It successfully creates a window that loads the content from index.html.

However, the follow is unclear to me:

  1. Do I create an ‘app’ folder in the root folder and place the entire repo in there?

  2. How do I get Electron to start the server using node/express so that it actually runs the twitter aggregator I built?

I appreciate any clarification, thanks!


Assuming I understand the question correctly, main.js is just a node script therefore, you could embed your node/express server code into there OR, use the child_process module to spawn a new process that runs your current .js script.

Build your application however you want (structure) and get it working. You can run Electron from the command line to test your code. Just run electron . to run the main.js and start things up. Once you have things working, look into electron-packager. It will automate the build process for you by allowing you to specify the code location, the platform you want to build for, and an output directory. It will then bundle all necessary items together, place your code in an “app” folder and run as expected.