Build a Feathers UI project as an Electron desktop app

Feathers UI may be used to build Electron desktop applications with HTML/JS.

Note: Consider using a different target than Electron for creating desktop applications, such as native C++ (with the Windows, macOS, and Linux targets). While Electron is technically available for OpenFL, other targets are more mature and offer better performance.

Prerequisites

In addition to the dependencies specified in the Feathers UI installation instructions, building an Electron application with Feathers UI has some additional requirements.

  • Node.js

  • Electron may be installed using the following command:

    npm install -g electron
    

Build

To build for the electron target, run the following command.

openfl build electron

Use the -debug flag to create a build to include extra debugging information that a web browser can use to map exceptions and stack traces back to the original .hx files.

openfl build electron -debug

The build's output will be written to the bin/electron/bin folder.

Your project.xml file may optionally specify an output folder different from bin.

<app path="Export"/>

In the example above, the output would be generated in Export/electron/bin instead.

Run / Debug

OpenFL provides the test command to launch your project using Electron.

openfl test electron

Troubleshooting

Error on macOS says "electron: command not found"

Electron is not installed globally. Run the following command to install Electron.

npm install -g electron

Error on Windows says "'electron' is not recognized as an internal or external command, operable program or batch file."

Electron is not installed globally. Run the following command to install Electron.

npm install -g electron

Did you get some other error message that you don't understand?

Configuring OpenFL builds for various targets can be a little tricky! Head over to either the Feathers UI community forum or the Feathers UI Discord. Explain which command you tried to run, be sure to mention that you are targeting electron, and post the error message (and any additional relevant output). Ideally, we can help you figure out a solution, and then we'll also add it to this troubleshooting section, so that everyone can benefit.