Node red change machine

Morning all,

I have been running my Node Red/MQTT server on a Pi (Debian Buster) for 2 years but now things are getting serious and I have two houses reporting to Node Red and my little Pi is getting slow. I now have a new machine (Lenovo M73 with ubuntu server & 1tb hard drive / i7 cpu) which I have prepared with MQTT and Node Red (using same credentials to make things easy). I want to take the whole of the Pi Node Red over to the Lenovo Node Red (and turn off the Pi for good).

The new Lenovo Node Red and MQTT server runs V4.02 of Node Red, the old Pi Node Red runs version V3. Can I just export all flows and then import them to the new updated server (adding in palette's that I have added on the Pi once the import is complete - I dont use Pi specific nodes on the Pi Node Red machine) so they run correctly or is there a better way?

I do not use snap plugings on the new Lenovo server, I kept things simple and installed NR/MQTT via SSH the standard way.

Cheers

Dan

You need to take most of the node-red userDir folder and sub-folders over to the new device.

Copy everything except any node_modules folders. Then, before (re)starting node-red on the new device:

cd ~/.node-red
npm install

I'm assuming that the userDir folder is ~/.node-red. Change that if needed. Then restart node-red and you should be good to go.

Of course, you might still need to tweak a few things. For example, if you access files/folders, you might need to tweak for the new device.

I must admit though, I personally like setting things up cleanly. So whenever I've migrated to a new device, I tend to set everything up from scratch, install the required nodes on the new device, reconfigure settings.js, and then export/import the flows.

1 Like

Just to add to @TotallyInformation's advice, it is a good idea to make sure that any extra nodes you have installed are on the latest versions, so they should be compatible with the (possibly) later version of nodejs you have on the new machine. You can do that using Manage Palette which will show you any that can be updated.

1 Like

Another thing that sometimes catches people out while moving their flows is that the default filename includes the hostname of the system (e.g. "flows_rpi3.json").

If your settings.js file DOES name the flows file, you should be fine -- otherwise, just rename the files on the target machine, before starting node-red on the new system.

1 Like

It appears that v4 now defaults to using just flows.json now. This has tripped me up many times in the past when "cloning or moving systems". It is IMHO a very worthwhile change to the defaults.

OTOH breaking a function node because

x=msg.whatever*0.1;

Now needs to be:
var x;
x=msg.whatever*0.1;

Is IMHO not helpful, especially when no error message is given about what is wrong.

I generally export my flow to a file and then import it to the new machine which works around the flow file naming issue, but when you copy or clone, it is something that can trip you up. Password encryption is another thing that can trip you up, but I prefer to re-enter any needed passwords on the new system.

It doesn't need to be that, it will still run ok as it was. The issue is that the original code should have been flagged, that code has always been wrong.

The code will be marked with a red squiggle in the editor and if you hover over that it will tell you what is wrong.

In fact you should generally not use var either. Let or const are preferred.
let x=msg.whatever*0.1

I think that was changed in v3 or even v2, not sure which.

1 Like

If you dont want to be informed of poor code, then you can turn off the helpful hints in the settings. In fact you can revert back to the old ACE editor and never have to worry again about writing good code ever again.

tongue firmly in cheek :wink:

the editor tells you
image


And as colin states, this has been like this since Monaco editor was introduced (which was V2 and then set as the default in V3)

Haha, you are right... but some scars never really heal, I guess.

Given that my first foray into node-red was on 0.17.x I doubt that is my only piece of advice that will be "out of date".

And don't forget to "get off my lawn"! :grin:

I think mine must have been v0.5 towards then end of 2013.

Hello again,

Thanks so much for all your help. In the end, I took your advice and, not wanting to copy over things I no longer use, (when I first started with NR, I tended to use more of the pre made nodes available to perform tasks, now I like to use the function node and write a bit of code - learning from these forums as I go on writing code) using the old NR server as my reference, added all the latest versions of the nodes needed a fresh. I then picked my tabs, exported each one and imported in the new NR. I had to change the MQTT links to the new machine but all seems to be working (very very much faster). NR 4.2 is a nice step up too. So I owe you all a beer :slight_smile:

Dan

3 Likes