Node-red running on root issues

Hi

I could not find the original node-red i installed with additional nodes with some flows after i did the changes in pictures below.

I installed Tjbot nodes and libraries and followed the instructions. After reboot i run node-red and the additional nodes all gone.

I tried running using root by going to sudo su and still can't get back to the original ones.

Please help.

Thank you

source:


If you are planning to run Node-RED as root you should be aware of the implications of doing so.

But if you want to get it working what is the full path of the nodes directory you installed the node in? Did you edit the settings.js file in the as per the instructions?

There really should be no valid use-cases for running Node-RED as root. Really not ever recommended.

Now I am sure that someone can come up with an exception or two but in general you will be a lot happier and more secure by not doing it. :smile:

2 Likes

Especially for an application that runs a web interface and has the exec node.

1 Like

i also have same issue when i start up the VM, i cannot deploy so i kill node-red
run with sudo make changes and reboot the machine...

is this the way this shuld work?
for me its ok ,Node red is locked till i go into the VM and make the cahnges
so no one other then me can got to the UI and move stuff around

but if there is any other approch please tell me
i am getting tired of killing to node every time i need to make a small change

I expect this is due to you having to use sudo. Unfortunately, you need to strip out your current installation of Node-RED and all globally installed nodes then reinstall either using a standard installation or using a local installation under the user that will be running Node-RED.

When using a standard installation, while install of NR itself may require sudo (as it will be globally installed), you should run it under a standard user - it will create the userDir folder as ~/.node-red and you install further nodes into that folder (or use the admin menu which does the same thing).

In my personal opinion, installing Node-RED globally opens potential security issues anyway and I prefer to avoid that. However, this shouldn't be an issue if access to your server is tightly controlled. But I personally prefer not to take the risk - especially the risk of forgetting as requirements creep over time.

A local installation of Node-RED is very easy and has other potential advantages too. The reason it isn't the default method is that it is more work to set up and is confusing for novices. However, once done, it is trivial to manage.

Create a folder for the installation under the home folder for the user that will run Node-RED. Do npm init in that folder then do npm install node-red --save. You then need to create a data folder which becomes the userDir, I create that under the master node-red folder. Adjust the startup command to use the custom userDir and you are good to go. Of course, this doesn't create a systemd startup command - let me know if you need to know how to do that.

For me, the advantage is not only security but it allows me to run multiple instances of NR with separate userDir folders or even run different versions of NR quite easily. Also keeps everything in one place.

thanks for the answer i think i will stick with my current method as lame as it is
as you said i am a noobie