(Solved) How to able Node-Red to create files and folders on DietPi

The path is /home/data/
Do you think there is a path where Node-Red can write?
I'm gonna try give permission for all to the folder if with that Node-Red can create a file would be great.

That worked!
I gave permission to everyone write and read the folder and then the Node-Red can create files and folders inside it.
This is good enough for my project.
Thank you all guys! :slight_smile:
The command for future reference is:
sudo chmod -R ugo+rw "path of the folder"
I hope this topic can help people with the same problem.

Node red can write anywhere that the user running node red can write. Since you are running as the user pi then node red will be able to write anywhere in /home/pi without you needing to do anything. If you want to be able to write somewhere else then you will have to allow pi access to wherever you need to write. This is nothing to do with node red but is normal Linux operation.
For saving stuff from node-red I usually use something like /home/pi/data, then there is no problem.

Colin, he is NOT running as pi. He is on the DietPI distro that does things differently. NodeRED runs as a user called nodered, so by default won’t have much accesss.

OK, has this thread been retitled? I am sure in the original title it suggested he was user pi but wanted root privileges.

Ah, that explains things. Well the nodered user will need adding to the appropriate groups of course.

Yes,I have changed the topic name after finding the solution to a more accurate title for future references.
After your question about the folder I realize that I could give the permission to the folder so anyone could red and write there even Node-Red.
That is the a parcial solution but enough for my project.
As dceejay sad, I'm running DietPi and that causes some problemwith the normal permission and I think due to the service not running as sudo or something like that.
I'm new to linux so I'm not really sure.
Thanks for all the help.

No service should run with root privileges unless it needs access to core capabilities of the device/OS. It is always better to run services in their own user space and then make sure that the user ID is given only those privileges it really needs.

For me this not work. I receive messages like this: /root/data/persistence.json: EACCES: permission denied, open '/root/data/persistence.json' Any help?
Sorry for my english. Thanks.

As this thread is as year old, lease open a new thread and explain the issue you are having. Let us know what

  • platform you are running and OS release
  • what version of NR and node.js (see node-red startup log)
  • export your flow and attach it to a reply (see this thread first)

also - EACCES means the user running node-red does not have permission to access the file specified.