Pacharapol Withayasakpunt Pacharapol Withayasakpunt
Thu 4 July 2019
Create an Electron app from any web server in any programming language.

Create an Electron app from any web server in any programming language.

As Electron is actually an containerized extended Chromium web engine, I reckon that this must be possible somehow. However, by default, Electron uses ipcMain/ipcRenderer rather than http or websocket...

As for a lazy reader, you can see my example project at, which is Python Flask in Electron. There is also a pure TypeScript version --

Finding a random PORT

You might use Just make sure you don't use too common a port number.

Containerizing web server

This is quite easy for Python, using For a guide on how to add data files, you might follow

For Java/Kotlin/other JVM languages, you might use, i.e. fat JAR, shadow JAR, uber JAR.

For JavaScript/TypeScript itself, you don't need containerizing, but make use you use absolute path, relative to __dirname for everything, and avoid hidden imports. For Express.js, at least pug and ejs templating engine works, but make sure to use pug.renderFile() and ejs.renderFile(). You can avoid this altogether, though, by making use of static files.

Starting web server at app start, and killing web server at app exit, including on errors

For non-JavaScript, see

For JavaScript/TypeScript, see

To kill on error, you might try doing a cleanup action just before node.js exits

Webpack-dev-server settings


Have only tried http and Never tried websocket directly yet, though.

This allows you to run Electron in your default web browser in development mode using two terminal, webpack-dev-server, and another running your default web server. Make sure to hide Electron specific code on development, though; otherwise it will throw an error in Webpack and in web browser.

Electron builder, and file associations

This might give you some ideas --

asarUnpack is needed for Python and static files. --