I rebooted my pi and now cannot start node-red. In case it helps, two recent nodes I added were node-red-contrib-mytimeout and node-red-contrib-stoptimer, but only mytimeout is actually in my flow. Here is the output when I try to start node-red:
Welcome to Node-RED
18 Apr 20:34:11 - [info] Node-RED version: v0.20.3
18 Apr 20:34:11 - [info] Node.js version: v8.12.0
18 Apr 20:34:11 - [info] Linux 4.14.71-v7+ arm LE
18 Apr 20:34:12 - [info] Loading palette nodes
18 Apr 20:34:17 - [info] Dashboard version 2.14.0 started at /ui
18 Apr 20:34:18 - [info] Settings file : /home/pi/.node-red/settings.js
18 Apr 20:34:18 - [info] Context store : 'default' [module=localfilesystem]
18 Apr 20:34:18 - [error] Failed to start server:
18 Apr 20:34:18 - [error] Error: Error loading context store: SyntaxError: Unexp ected token u in JSON at position 0
at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/c ontext/index.js:177:15
at
I edited my settings.js file to comment out the context storage to localfilesystem and node-red will start. But then when I re-enable the localfilesystem context store I just get the same error. Perhaps I should just delete the file with the error and let it build it again? Is there something I did that would cause this error, like perhaps an incompatibility with the new nodes I installed?
I ended up removing all the folders and files from my context folder (I backed it up first just in case this was bad), and now I can start node-red with context enabled and I see it repopulated that folder with context folders.
Not such a big deal, but would be nice to know if I did something dumb to cause this problem.
The u is often from it reading it as unicode (uXXXX style ) - so no point looking for a u specifically. - But yes please - if you do still have the context files somewhere and they don't contain any personal data, it would be good if you could zip and post them either here or to team@nodered.org
Yes, I still have the files, and now that I actually open and look at them, they all just read "undefined". There are 16 folders with names like "ac17cdff.38736" and inside the folders there are two files, one is just "flow.json" and the other is a long name like: "2f764e58.e7d6a2.json". All of the json files read "undefined".
My new context folder has 12 folders now and inside some is just a "flow.json" and in others there is "flow.json" and sometimes multiple longer name ".json" files. All of those files contain actual values I entered in or recorded in my flows.
Sometime last night though my flow lost its values, but I was also making changes to my flow and perhaps I just didn't notice that it lost the values at that point. It seems like making changes to a flow often results in losing the context you had. But that probably makes sense if you re-route something and definitely if you remove a flow variable.
My original problem however was simply from shutting down the pi and then powering up again. I did not stop node-red however prior to shutting down the pi.
Welcome to Node-RED
===================
24 Dec 09:16:43 - [info] Node-RED version: v0.20.7
24 Dec 09:16:43 - [info] Node.js version: v10.15.3
24 Dec 09:16:43 - [info] Windows_NT 10.0.17763 x64 LE
24 Dec 09:16:45 - [info] Loading palette nodes
24 Dec 09:16:47 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
24 Dec 09:16:48 - [info] Dashboard version 2.30.0 started at /ui
24 Dec 09:16:49 - [info] Settings file : \Users\SESI009727\.node-red\settings.js
24 Dec 09:16:49 - [info] Context store : 'default' [module=localfilesystem]
24 Dec 09:16:49 - [error] Failed to start server:
24 Dec 09:16:49 - [error] Error: Error loading context store: SyntaxError: Unexpected token in JSON at position 0
at C:\Users\SESI009727\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\context\index.js:177:15
I tried to delete the folder context and I had another error:
Error: Cannot find module '../context'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\Users\SESI009727\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\flows\index.js:26:15)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
If someone can help me I would be grateful.
Thanks
If it was C:\Users\SESI009727\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime\lib\nodes\context\ then you have deleted parts of the Node-RED source code.
You will need to reinstall Node-RED.
Let's deal with that first. You are using a very old version of Node-RED and node.js. But let's get you running again.
Delete the directory C:\Users\SESI009727\AppData\Roaming\npm\node_modules\node-red\node_modules\@node-red\runtime
Open a terminal in the directory C:\Users\SESI009727\AppData\Roaming\npm\node_modules\node-red
Run the command npm install - that should get the @node-red/runtime module reinstalled
Now, to fix the context error. The context data is stored under \Users\SESI009727\.node-red\context
Look under that directory for any JSON file that is empty or contains just the word undefined. Delete those files. Or, just delete the context directory as a whole if you don't care about the data.
Hello knolleary,
Thank you for your answer.It's working again. I did keep the folder as a backup, so I just put it in place and deleted the context data as mentioned.
Have a great day