many thanks for trying to work around this for the last 2 days. Let me try to help with DietPi, even if my knowledge on Node-Red is limited. Indeed the normal Node-Red installer is not working on DietPi. Therefore DietPi own software catalogue to be used.
root@DietPi3: bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
Diet-Pi detected - only going to add the node-red-start, -stop, -log commands.
Flow files and other things worth backing up can be found in the /mnt/dietpi_userdata/node-red directory.
Use the dietpi-software command to un-install and re-install Node-RED.
root@DietPi3:
All Node-Red data is stored in the following location: /mnt/dietpi_userdata/node-red
@devifast
Little advice in general: When you face issues with software that was not installed via installers/methods of the developers/creators themselves, it is good to report the issue to the distribution maintainers first, in this case DietPi: https://github.com/MichaIng/DietPi
This allows us to check whether it is an issue with our implementation or with Node-RED in general and we can then forward it if required. If it is really an issue with Node-RED this would allow us implement a workaround until an upstream fix exists.
Similarly when you install a package via apt-get install and face an issue with issue with it, best is to report first to the Debian maintainers (okay on RPi its Raspbian, but they share 99,5% of implementations): https://www.debian.org/Bugs/
The result should match exactly (besides moved data dir and systemd service) the official generic install method which calls sudo npm and this is what the RPi installer does as well.
Since after npm install on DietPi the node-red binary is first any only touched by the nodered user with /mnt/dietpi_userdata/node-red, why does the persist node choose /root/data as default storage while on Raspbian with installer it chooses /home/pi/data by default? I cannot find any part of the installer the assigns a different default dir somewhere .
But generally, if Node-RED does not use the executing users home or current working dir for data/configs, is there a way to set the default data dir via script for all nodes?
Now I see we do not set the WorkingDirectory via systemd unit, probably this would help. Will do some tests as well.
Now another problem. I make file named persistence.json with folowing comand:
touch persistence.json
but this error is displayed
"/mnt/dietpi_userdata/node-red/persistence.json: Unexpected end of JSON input"
Basically the file would be created by Node-Red automatically as soon as data are flowing in. Anyway you can change the owner of the file to nodered user. This will ensure that Node-Red is able to read/write the file.
The error Unexpected end of JSON input is as expected, because you have an empty file without anything in. This should change as soon as data are stored inside the file.
The solution turned out to be quite simple.
I used the chmod command as follows:
chmod 666 persistence.json in directory shown to me by Joulinar
Before i use the comand I saw that
-rw-r--r-- 1 root root 0 Jul 7 20:19 persistence.json
after execute comand i saw that
-rw-rw-rw- 1 root root 0 Jul 7 20:19 persistence.json.
Thanks to everyone who joined this discussion to help. Thank you very much.
I am a beginner in the field of Linux and it is quite difficult for me, but thanks to responsive people like you, things are gradually taking shape.
I'm sorry for my bad English.
Thanks.
link: http://linuxcommand.org/lc3_lts0090.php