I am a node.js beginner and I am trying to read a json file, but when I\'m running \'npm start\' in the terminal I get this error:
undefined:3462
SyntaxError: U
readFile doesn't have a return value. You are trying to parse "undefined" as if it were JSON. The file is passed to the callback function after it has been read.
fs.readFile('./files/sample_data.json', function (err, data) {
if (err) throw err;
var config = JSON.parse(data);
console.log('Config: ', config);
});