Wednesday 20 September 2017

“Unexpected token in JSON at position 0”?

I'm writing a node.js module which imports a JSON file:const distDirPath = "c:/temp/dist/"; const targetPagePath = "c:/temp/index.html"; const cliJsonPath = "C:/CODE/MyApp/.angular-cli.json"; const fs = require('fs');function deployAot() { var version = JSON.parse(fs.readFileSync(cliJsonPath, 'utf8')).version; }// export the module module.exports = { DeployAot: deployAot }; I validated the contents of the json file above in https://jsonlint.com/ and it's valid json but the first line of code above in deployAot() returns the following error when I exec the node module:"Unexpected token in JSON at position 0"Here's the json being imported:http://ift.tt/2w7OebK idea what the problem might be here?

Submitted September 20, 2017 at 11:16PM by random503

No comments:

Post a Comment