JSON.parse() causes error: `SyntaxError: Unexpected token in JSON at position 0`
You have a strange char at the beginning of the file.
data.charCodeAt(0) === 65279
I would recommend:
fs.readFile('addresses.json', function (err, data) {
if (data) {
console.log("Read JSON file: " + data);
data = data.trim();
//or data = JSON.parse(JSON.stringify(data.trim()));
storage = JSON.parse(data);
}});
JSON.parse()
does not allow trailing commas. So, you need to get rid of it:
JSON.parse(JSON.stringify(data));
You can find more about it here.