I'm new in node js and I'm trying to parse a JSON. This is what I've done so far:
const JSON = require("nodemon/lib/utils");
...
someFunction() {
let sens = [];
// sensor is the result of fs.readFileSync call and file is a json array
sens = JSON.parse(sensors);
It throws me:
JSON.parse is not a function.
How can I solve it?
const JSON = require("nodemon/lib/utils");?JSON.parse()is a standard JavaScript function supported by Node.js. You overwrite theJSONobject in your first statement and this is why it doesn't work.