Portable Node-RED v2.1.3

Today I needed a portable version of Node-RED to do something on a machine that I don't want to install Node onto and was pretty pleased with the result I got using electron-forge.

I know others have accomplished this before but I thought this came out pretty clean so I decided to share.

Download: nodered-portable download | SourceForge.net (Windows x64)

Github: GitHub - mdkrieg/nodered-portable: Node-RED Portable Version via Electron

Hope you find this as useful as I did,
Cheers!

5 Likes

Have you used standard 1880 port or switched to using another one?

Port 50820, picked by a random number generator. Changed it to not collide if already running node-red on port 1880. Ideally I'd like to find a way to customize this at launch.

1 Like

Apart from the exercise :slight_smile: any reason not to use Node-RED desktop?

4 Likes

Is this portable in the same sense as for example LibreOffice Portable?
That is, it does not require anything to be installed on the target machine, all components can be on a USB flash drive?

I try not to install anything on my Windows PC except the PortableApps platform.
Node-Red is installed on a Raspberry Pi but I can see uses for a USB Windows installation.

Normally done by referencing an environment variable in settings.js - see my alternate installer for examples.

You won't be able to have a single portable version that works across platforms without carring copies of the (enormous) node_modules folder. That's because Node.js allows compiled C/C++ libraries which compile to different executables on different platforms.

Hmm. Well, storage is cheap!

I don't expect it to work on different operating systems, No idea how other portable apps deal with processor architectures.

But on one of my Raspberries I see ~220MB

du -sm /usr/lib/node_modules/ ~/.node-red
79 /usr/lib/node_modules/
140 /home/pi/.node-red

No doubt it's much bigger on WIndows! :thinking:

Not sure if this is of any use. Here is a tiny shell script that starts nr with the port number extracted from the current directory, so for example the nr directory holding the flow, settings and node_modules would be directory_name#xxxx where xxxx is the port number. If no # found then the default 1880 is used.

I also use yarn so that I can run multiple versions of node on the same host.

#!/bin/bash
###################
# start-nr.sh
# -----------
# launch node-red with the user dir as the current dir and a port.
#
# If the containing directory name ends in '#n' where n is a number
# e.g. directory-name#1880 
# then the number will be used as the node-red port.
######################

nr_root=$(pwd);
default_port="1880";
port_index=`expr index "$nr_root" "#"`;

if [ "$port_index" -eq "0" ]; then
   port=$default_port;
else
   new_port=${nr_root:$port_index};
   re='^[0-9]+$';
   if ! [[ $new_port =~ $re ]] ; then
      port=$default_port;
   else
      port=$new_port;
   fi
fi
params="";
for param in "$@"
do
   params+=" "$param;
done
re='admin';
if ! [[ $params =~ $re ]] ; then
   cmd=$nr_root"/node_modules/.bin/node-red -u "$nr_root" -p "$port;
else
   cmd=$nr_root"/node_modules/.bin/node-red"$params;
fi
#echo "cmd="$cmd;
exec $cmd

For yarn I just batch up a list of commands that I keep in 'yarn-init.sh'.

yarn add node@14.17.5
yarn add node-red@2.1.3
yarn add node-red-dashboard@3.1.0
1 Like

The exercise was a big part of it which is why I took care to include a walkthrough in the repo.

For me the reason not to use something like Node-RED desktop is that I now use NR for many of the things I used to use Python for (in this case translating and XML database to a flat file) where I want to make a script and throw it in a drawer until I need it again. And in this case, NR beats the pants off python since all my dependencies are portable too :slight_smile:

I think some would preach Docker here but I have zero experience with

1 Like

Update 1.1.0

Added configuration inputs to the initial screen, clicking START launches Node-RED:

I'm very happy with this!

(nodered-portable download | SourceForge.net)

3 Likes

Downloaded and ran it -all looked good until I tried to install a node

Yup, same problem for me when I decided to actually try installing from palette.

Luckily the solution was very simple. Node-RED was installing palette modules to the folder "./home/node_modules" and so while it was downloading the modules they weren't properly registering with NR. I changed the default settings from userDir:"home" to userDir:"." and it looks to be working now (I tested final portable file as well).

(download latest file " nodered-portable-v1.1.1-win32-x64.zip" from same link above)

I have the same problem. Please tell me in which file you made this change. Or can you do it via the configuration menu? I have not found an entry.

Hello @mweissen and welcome to the forums. The palette modules not working should be fixed in the v1.1.1 version, it should download the latest automatically from sourceforge. I just deleted all the old versions anyway so you should be good if you just download again.

Let me know if the issue persists and I'll look into it.

Hello Matthew!

Thanks for the quick reply. First of all: now everything works.

Yesterday I tried first the version 1.1.1, but without success. So I tried it first with the older version - with the known problems. Now I have loaded the version 1.1.1 again and everything works. Thanks again!

I plan to give a workshop on home automation to teachers in April 2022. NodeRed is an interesting tool for this. For the practical exercises, nodered-portable is a very pratical tool. I will be happy to base the exercises on it.

Regards, Martin Weissenböck, Vienna, Austria

2 Likes

Hello Matthew!

Good job!!

In this release how can I start nodered without pressing "START".
I need to automatically start nodereded (with default port-httpAdminRoot-httpNodeRoot) when operating system starts.

Optionally, the (port-httpAdminRoot-httpNodeRoot) settings in which file can be changed?

Thanks in advance.

Roberto

That would interest me too :wink:

Hi,

I believe that on the 'Inject' node there are options at the very bottom of the page. One of them is "inject once after X seconds" or similar....

I vaguely remember that with older version of node-red I used "npm install node-red-contrib-startup-trigger" that 'forced' the flow to ALWAYS start on deploy no matter what.

Cheers,

Paul

Hi
just downloaded the 1.1.1, as I'm starting to learn node red.
Unfortunately I can't find the menu item Palette to get new nodes, but in all the pictures here in the post I can see the item is there....
Do i something wrong?
Thanks
Andrea

What does your screen look like when you click on the burger menu?

It should look like this