How to save node red flows in local directory

Here it is shown how to save node red flows in any local directory on your PC/Laptop. Node red saves the flows and files in C directory which can be problem if your C drive is getting full. C drive is usually used for OS and program files many want to save working files(which can get large) in other drive. So here we will create a working folder in D drive. Also here it is shown how to use the node red export feature to save the flows and nodes. There are other ways to save the flows such as copying a flow or nodes in clipboard and the saving it in a text file and then later on importing the flow or nodes by pasting it. But this manual process can be tedious which makes using exporting simpler. 

If you are new to node red then see the previous node red tutorial Node Red with Arduino Simple Example. Basically, node red is open source platform to build web application, especially useful for building Internet of Things applications(IoT applications).

Now it is explained how to save flows in node flows. After fresh install, node red saves the flows in the default node-red flow file location which is the folder .node-red located in:

C:\Users\<username>\.node-red

where <username> is the name of the window user which can be different for you.

An example is shown below.

node red folder

The default user folder contains files and folders such the main settings.js file(node-red configuration file), the lib folder where flows are saved when exported from node red user interface, the current used flow which is flows.json, the node_modules where the pre-installed and newly installed modules are saved.

You can see that node red uses the main node-red configuration file called settings.js file, the current flows.json from this default folder when you start up node-red from cmd or powershell as shown below.

node red running

Now to change the node red default user directory we have to edit the settings.js node-red configuration file. Say that the new user folder is created in D drive in folder called nodeRed. Then we have to enable the userDir path in the settings.js file which is illustrated below.

user directory setting in node red


 So in this case we have to write:

userDir: 'D:/nodeRed/',

Don't forget the comma "," at the end.

The  nodeDir path is optional but it has also been set here inside the nodeRed/nodes.

If you re-run node-red from the cmd/powershell you should see that node-red will use the settings.js from the default user directory but now will use the new user directory D:/nodeRed for new flow. This is shown below.

new user directory in node red

The content of the new node red user directory (D:/nodeRed) is shown below.

node red user directory in D drive

At this time the lib folder contains another empty folder called flows(as in the default user directory in C) and the node_module folder will also be empty. 

If the node red is now opened in the browser we will see an empty flow.

node red flow

Now after a flow is created we can export the flow using the export button.

export flow in node red


In the export window, to save the flow select current flow. Then select Local and in there select flows directory(you can create a new folder inside the flows directory). Then at the bottom click the Export to library button as shown below.

export to library in node red

After this the selected flow is downloaded into the newly created user directory inside D:\nodeRed\lib\flows as shown below.

The last thing to do is to copy modules inside the node_modules from the default user directory in C drive into the node_modules in the newly user directory D drive. Only the newly added modules via the Manage pallets needs to be added. Any new modules added will be downloaded and installed in the newly added D:\nodeRed\node_modules.

Also the previously used flows can be copied from the previous user directory location into the new directory location and then simply imported.

And that's it. 

Now one can create flows and save in this new user directory with node red. If you interested in building web application and IoT application with node red which can be run from your home with public IP address then check out the tutorial Deploy Arduino Red Node App on Web with Cloudflare Tunnel. Other red node based IoT application are as follows.

- IR Proximity Sensor IoT Application


Post a Comment

Previous Post Next Post