TotallyInformation / alternate-node-red-installer

An alternative installer for Node-RED. Avoids global installs, no admin rights required.
MIT License
25 stars 5 forks source link
node-red

alternate-node-red-installer

An alternative installer for Node-RED. Avoids global installs, no admin rights required for new Node-RED instances.

This solution is particularly suited for development environments and anywhere that you don't want to install global NodeJS scripts. Also when you need to have different versions of Node-RED running in parallel.

Getting Started

  1. Make sure that you have Node.JS correctly installed. Check that you can run it manually from the command line with node --version && npm --version.
  2. Make sure that Node.js is at least at version 8.16.0 (LTS) or above.
  3. For ease of use, install this package globally with npm install -g alternate-node-red-installer. You may need to use a command line with elevated rights (sudo on Linux).

Now, from any command line, you should be able to run the following:

alternate-node-red-installer -f <root folder name>

Where ` is a relative or absolute folder path that you want to be the root of your new Node-RED installation.

Instead of the long-winded executable name, you can also use nrinstall

Example (for Mac, Linux or Windows PowerShell):

nrinstall -f ~/nrtest

Once the install has completed (it may take some time), you can navigate to the data sub-folder and work with Node-RED as normal (e.g. cd ~/nrtest/data).

You may wish to adjust the settings.js file and install any required Nodes at this point.

Run npm run to see the run commands available for your convenience. They are detailed in the README.md file installed in the data subfolder.

These instructions should work on any platform supported by Node.JS.

Table of Contents

Introduction

Node-RED is a superb, flow-based development and prototyping tool written by IBM to showcase their IoT experience. It was later gifted to the JavaScript Foundation. It is entirely JavaScript based thanks to NodeJS and a number of other great libraries such as D3, ExpressJS and JQuery.

I've used it now for a few years to create a custom home automation system and was impressed enough to start trying to give back to the community.

The issue

However, I've never personally quite liked the default installation. Don't get me wrong, it is great for beginners and for people inexperienced with the command line. But for production use and for security, I think that there is a better way to install and maintain your Node-RED systems.

In particular, Node-RED itself (and the companion node-red-admin module) are normally installed globally.

Not only can this open up security issues by having complex, inexperienced user generated code running under a global service, it also makes some of the files under the surface difficult to find on the odd occasions you need to.

The solution

There seems to me to be an easy solution to the global installation issue. This approach is more complex to set up normally since you don't, of course, get any hand-holding to set it up. And so the idea for this code came about.

The concept is really very simple.

That's it.

Having a script to do this means that you can install Node-RED anywhere you like. Install two copies, ten if you want. Have different versions of Node-RED running in parallel. All really easy.

This works on any platform that Node-RED will run on.

The advantages

The advantages of this approach I believe are:

Starting Node-RED

When using this method, uou can start Node-RED manually from either the master or the data folder by simply typing:

> npm start

The start script tells Node-RED of the correct userDir folder (the data sub-folder). You can also use the start script with any other method you may wish to use of starting Node-RED (Windows Scheduler, systemd, PM2, nodemon, etc.)

Updating Node-RED and installed nodes

If you have installed the two package.json files in this repository, you will find that they contain npm run ... scripts such as check-master and update-data. These scripts do everything necessary to see if anything needs updating (reporting back to the console) and actually doing the updates correctly.

So from either the master or the data folders:

Each of the two package.json files also has a simple check and update run script that applies to the corresponding folder.

If you lose track of the script names, simply run npm run to get a list.

Changes

Please see the CHANGELOG file.

To Do

Please see the TODO file.

Prerequisites