This is an Electron template to embed Node-RED with an existing Node-RED project to create a native application.
 
 
Go to file
Dave Conway-Jones 5312ec9dd4
Fix import of is-dev
2024-01-23 14:12:26 +00:00
.github Create no-response.yml 2019-10-13 22:43:01 +01:00
.vscode add kiosk mode (dangerous) 2019-10-26 18:30:16 +01:00
build bump electron version - add dmg installl bgnd 2019-11-08 23:28:17 +00:00
example Tidy flow 2020-10-06 11:49:19 +01:00
.gitignore Bump to Node-RED 1.2.0 2020-10-15 14:25:30 +01:00
.travis.bak remove travis job 2020-11-17 23:44:04 +00:00
LICENSE update README and License to Apcahe-2 2019-10-23 23:46:16 +01:00
README.md Update README.md 2020-05-05 19:34:45 +01:00
console.htm redo file import and save 2020-10-05 00:00:45 +01:00
dockerbuilder Don't auto hide View menu on windows and Linux 2019-11-16 23:44:59 +00:00
electronflow.json Bump to 1.3.5 2021-05-18 22:25:42 +01:00
electronflow_cred.json add loading page for slow devices 2018-08-27 14:45:40 +01:00
load.html add loading page for slow devices 2018-08-27 14:45:40 +01:00
loading.gif Better loading icon and demo flow 2016-10-30 23:03:12 +00:00
main.js Fix import of is-dev 2024-01-23 14:12:26 +00:00
merger.js tidy up touchbar 2020-10-10 17:10:47 +01:00
nodered.png major upgrade to latest electron and builder 2019-10-23 17:40:06 +01:00
nrtray.png add optional tray icon, menu etc 2020-06-01 17:38:23 +01:00
nrtray@2x.png add optional tray icon, menu etc 2020-06-01 17:38:23 +01:00
package-template.json Bump to Node-RED 1.2.0 2020-10-15 14:25:30 +01:00
package.json Fix import of is-dev 2024-01-23 14:12:26 +00:00

README.md

Electron Node-RED

platform GitHub version GitHub license

This is an Electron template to embed Node-RED with an existing Node-RED project to create a native application.

This is not intended to be a useful tool as-is, but as a base for you to create your own versions. You will need to edit the main.js to suit your application and update the package.json file to include your own required nodes and dependencies.

There are several simple switches that can be set in the NRelectron section of the package.json file. More significant modifications will require modification of the main.js file. Have fun.

Wrapping an existing Node-RED project

The merger.js utility should be run from within this projects directory and can be pointed at an existing Node-RED project directory. It will try to copy over and package up the relevant files into this project ready to install and build - so the simple flow would be

./merger.js {path to my Node-RED project directory}
yarn
yarn start

This uses the package-template.json file as the main electron setup - so you should edit any build parameters, product name, whether you want the app version to be editable, run in kiosk mode, etc in the NRelectron section before running.

The app name, version and description are picked up from the package.json file of the original project.

When running using yarn start - the flow file is picked from the current directory. When running as an app (but only if editable), then the flow file is copied into the users .node-red directory and is read and written from there. The default name can be changed in the package.json file if required.

NOTE: Currently the settings are set around line 110 of the main.js file. If you do use any custom settings then currently you will need to modify this manually.

Configuring the project for building

This project uses the electron-builder project to help build native versions of Node-RED applications, so please read and become familiar with their documentation as some basic knowledge is assumed.

As a pre-req, as well as a recent version of node.js, you will need the yarn install tool.

# Clone this repository
git clone https://github.com/dceejay/electron-node-red.git
# Go into the repository
cd electron-node-red
# Install the yarn install tool globally
sudo npm i -g yarn
# Install project dependencies
yarn

Building local runtime

You should then be able to run

yarn && yarn dist

to create a runtime for your local platform. However - there may be some errors. If so they are usually fairly self explanatory, and may just require installation of another npm or brew or apt package, then retry the command.

Runtimes are created in the dist directory under the electron-node-red project.

Building for other platforms

Generally you can just add the required parameter to the command

yarn && yarn dist -w        // for windows (but use multi-platform builder below for building on Mac Catalina)
yarn && yarn dist -l        // for linux
yarn && yarn dist -m        // for mac

These will generally fail the first time through, and you will need to install some extra library in order to make it complete successfully.

The defaults are to build a .msi for Windows, a .dmg for Mac, and both a .deb and .rpm for Linux. These can be changed by editing the build section of the package.json file, see the electron-builder config docs for more information.

Building multi platform using Docker

Electron-builder has a pre-configured Docker image that can help you build cross platform images if you like Docker - again read their docs.

This is very useful if you need to build for Windows on a Mac as the electron-builder invokes wine which is only 32-bit and so can't be run under Catalina.

Developing and Testing - Running locally

While developing and testing you can just run your app locally by running

yarn start

from within the project folder.

The initial flow file is named electronflow.json along with it's credentials file electronflow_cred.json. Just copy your existing flow in instead.

The default is to start on the dashboard page - as this is intended to be just an application - without the Node-RED editor exposed to the end user, but there are some simple flags to to configure this within the package.json or at the top of main.js.