Run the Node.js file automatically after starting the Electron application

Im uses GitHub Electron to create a web-based desktop application.

I use Node.js as a server, my problem is that I do not know how to run the server.js file only when the electronic application starts.

I want to package the distribution application so that I can start the server without the $ node server.js command line .

+5
source share
1 answer

Just just require server.js file in your main file (e.g. app.js ):

 var app = require("app") , server = require("./server") ; ... 

And in the server.js file you can:

  require("http").createServer(function (req, res) { res.end("Hello from server started by Electron app!"); }).listen(9000) 
+9
source

Source: https://habr.com/ru/post/1239169/


All Articles