docascode / Node2DocFX

An API documentation generator for JavaScript.
MIT License
3 stars 3 forks source link

error for Json.parse on line 26 of node2docfx.js #12

Open yuan208208 opened 4 years ago

yuan208208 commented 4 years ago

When i execute "node nodemodules/node2docfx/node2docfx.js node2docfx.json", then throw exception: SyntaxError: Unexpected token in JSON at position 0 at JSON.parse ()_

And i found the code on line:26 in node2docfx.js: config = JSON.parse(fs.readFileSync(configPath));

Maybe it returns buffer array for fs.readFileSync,but "JSON.parse" needs a Json string, so i update the code to: config = JSON.parse(fs.readFileSync(configPath, 'utf-8').toString().trim());

And it works.