Cannot start server error loading context store unexpected token u in JSON


Hi all,

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

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.


Well the error message says that there is a 'u' at the start of the file that it isn't expecting. Did you look at the contents of the fie(s)?


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



The error is usually because it is trying to parse undefined


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.


How did you shut it down, and how do you run node-red?