Work with deployed flows on /ui and run the editor for different flows

My first flows are build and deployed at port 1880 and stored with .node-red/flows.json.
While the first version is in use, I would like to continue "working on it". I thought that this should go with a copy at another port e.g. 2000 and in another directory.
However, I see that when I start with
~/.node-red $ node-red -p 2000 -u /home/pi/.node-red/red2000
the Flows.json is taken from the .node-red directory.
I can't work with any other flows with this!
Note: the /red2000 was not build beforehand, I expected NR to create it by itself, and yes it did.

What should be the correct configuration?

~/.node-red $ node-red -p 2000 -u /home/pi/.node-red/red2000
29 Jan 17:59:26 - [info] 

Welcome to Node-RED

29 Jan 17:59:26 - [info] Node-RED version: v3.0.2
29 Jan 17:59:26 - [info] Node.js  version: v19.3.0
29 Jan 17:59:26 - [info] Linux 5.10.103-v7+ arm LE
29 Jan 17:59:31 - [info] Loading palette nodes
29 Jan 17:59:37 - [info] Dashboard version 3.3.1 started at /ui
29 Jan 17:59:37 - [info] Settings file  : /home/pi/.node-red/red2000/settings.js
29 Jan 17:59:37 - [info] Context store  : 'default' [module=memory]
29 Jan 17:59:37 - [info] User directory : /home/pi/.node-red/red2000
29 Jan 17:59:37 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Jan 17:59:37 - [info] Flows file     : /home/pi/.node-red/flows.json
29 Jan 17:59:38 - [info] Server now running at
29 Jan 17:59:38 - [warn]

Moved to general since this isn't a question about creating custom nodes.

I am surprised that does not do what you expect, however if you add the path to the flows file on the end then I think it will work
node-red -p 2000 -u /home/pi/.node-red/red2000 /home/pi/.node-red/red2000/flows.json

These both ways work:
Using an extra directory and extra port for the "Edit" task:

~ $ node-red -p 2000 -u /home/pi/.red2000
 --> [info] User directory : /home/pi/.red2000
 --> [info] Flows file     : /home/pi/.red2000/flows.json

Having the extra directory in the "default" directory:

`~ $ node-red -p 2000 -u /home/pi/.node-red/red2000 /home/pi/.node-red/red2000/flows.json`
 --> [info] User directory : /home/pi/.node-red/red2000
 --> [info] Flows file     : /home/pi/.node-red/red2000/flows.json

I wonder what advantages one or the other method has?!

Well diagnosed. The problem arises when the user directory is a subdirectory of the default. In fact that is not a good idea. I think npm will look in directories above the current one when loading modules, so putting flows in a subdirectory of the default is not a good idea, it could cause confusion. Therefore, I suggest using your first example, keeping the folders separate.

I am not sure whether this is a bug in the node-red command or not.

Just to complete the possibilities:
Here is another flows.json in the "default" directory and then started on a different port:
~/.node-red $ node-red flows_1304.json -p 2000
The "default" flows was started before and has no problem with this second start.
So now the second flows is not started in a sub-directory, but in the same directory as the default flows.json.
@colin: Does npm have similar problems as mentioned above, or is this cleaner?

Running it that way will use the same node_modules folder (where additional nodes are installed) and package.json and package-lock.json, which are where the node dependencies are kept. If your second flow is similar to the original, so they require all the same additional nodes, then that should be ok as far as npm is concerned. However, node red keeps status about, for example, the current settings in the editor (in the .config files) so node-red might get confused if you had editors open on both flows at the same time. Also, and possibly more serious, if you use file based persistent storage then they would be both using the same context files (in .node-red/context) which would be disastrous I think. So I think this is a bad idea.

So, bottom line:
-- start "default" with
~ $ node-red goes with .node-red directory

-- start second/next project with the other port like this:
~ $ node-red -p 2000 -u /home/pi/.red2000

The .red2000 directory would be build just with a cp of .node-red
Both projects work with "flows.json" in their respective directory

I think so, unless someone else pipes up with other ideas. One exception, though, if you want to run the same flows on multiple ports (though I am not sure why you would do that), then you can just use
node-red -p 2000
It would not be advisable to run the editor on both at once though.

It's just about running a working Flows.json on one device (e.g. RPI) and at the same time being able to use it with different devices (PC, Mobile, etc) using the Dashboard /UI.

It is NOT about using more than one editor instance to manipulate this Default Flows.json.

The goal is to be able to use other Flows.json with Editor and /UI during the default operation (Editor and /UI). This obviously makes sense only with different ports and separate directories.

Understood. That should be fine.

Another option might be to use the Projects facility in Node-RED.
Create a new project and cut-and-paste your flow into it.

I think you can only run one project at a time using projects, I believe @gNeandr wants to run one while working on another.

Oh - I see what he means (now). Yes - you can only run one project at a time.

The real question is: How can a nodeRED installation on a computer (e.g. RPI) be used in a way that a running project can be executed and on the other hand further work on other projects can be done.

See on page: Projects : Node-RED

Open an existing project
Node-RED only runs one project at any time. By opening another project you change what flows are running.

This is probably not the separation that is desired here.

See also Deploy a nodeRED project

Yes, multiple directories alongside .node-red, not below it, is the way to go I think.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.