4

So, i tried to make Electron app to run Express as the server and React as client. My step is basic one i think, first i generate electron with electron boilerplate and then inside the project that got generated, i generate express into server folder using boilerplate also, and inside the same electron project folder i generate react with create-react-app into client folder.

Here is my project folder structure:

project folder structure

client folder from create-react-app, server folder from express boilerplate.

In development i run express at port 30001 and react at port 3000. And using this script to run them :

"start": "concurrently \"cd ./server && cross-env PORT=3001 npm start\" \"cd ./client && cross-env BROWSER=none npm start\" \"wait-on http://localhost:3000 && electron .\"",

But, from this point i don't know a slight clue of how to build this.

Note: I have tried another react-electron boilerplate, and some just too much for me or some can't import node modules directly to reactjs i don't know why. I am using expressjs as bridge between my react and node modules. Any insight on better implementation would be greatly appreciated.

Afdal Lismen
  • 289
  • 1
  • 3
  • 11
  • What do you need express for in an electron application? There is no server and client in electron. There's only a main process and several renderer processes. – PeterMader Jul 29 '17 at 08:13
  • @PeterMader Well, I actually found a tutorial running expressjs and electronjs, he copied node.exe and node.lib into his project, and uses that to run the script, is that for server ? I never thought about server before, i tried install this install that and it run, but now i dont't know how to package it. – Afdal Lismen Jul 29 '17 at 08:30
  • I still don't understand why you need express in a desktop application as you don't need to serve files to a client. Just use the normal NodeJS file system API for that. – PeterMader Jul 29 '17 at 14:25
  • @PeterMader As you suggested i am moving from using expressjs now, instead i use electron ipc to connect react with electron and then electron to my database in my case i use nedb. But i still don't now how to package it. Maybe if you have some spare time you can look at [my question](https://stackoverflow.com/questions/45392642/how-to-add-folders-and-files-to-electron-build-using-electron-builder) about this. – Afdal Lismen Jul 29 '17 at 18:39

0 Answers0