Hi Guys!
I try to work with JSON file to persist important parameters and I using at first moment, to study the best way to handling it, I starting to read a file, to do it i using REQUIRE Method, and I had this error "require is not defined (line 1, col 10)"
My function GetJSON Parameters:
var fs = require('fs');
var obj = JSON.parse(fs.readFileSync('/home/pi/HomeGateway/nwkFilestorage.json', 'utf8'));
msg.payload=obj;
return msg;
My nodes:
[{"id":"8213a1aa.82424","type":"function","z":"36fc56fb.15e79a","name":"GetJSON Parameters","func":"var fs = require('fs');\nvar obj = JSON.parse(fs.readFileSync('/home/pi/HomeGateway/nwkFilestorage.json', 'utf8'));\nmsg.payload=obj;\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":120,"wires":[["136175e2.bd12fa"]]},{"id":"136175e2.bd12fa","type":"debug","z":"36fc56fb.15e79a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":120,"wires":[]},{"id":"2a056dd2.f9a382","type":"inject","z":"36fc56fb.15e79a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":90,"wires":[["8213a1aa.82424"]]}]
The error:
I have checked "setting.js" and I didn´t see anything to fix at the first moment.
My nodes:
My Settings:
Can someone have any idea how to fix it?
Best Regards,
Alex