hallo sam :-)
i have now this in my node_helper.js:
var NodeHelper = require("node_helper");
// add require of other javascripot components here
// var xxx = require('yyy'); here
const csv = require("csvtojson");
const csvFilePath = this.path + 'birthdaylist.csv';
module.exports = NodeHelper.create({
init(){
console.log("init module helper perlchamp");
},
start() {
console.log("Starting module helper: ${this.name}");
console.log("dieser Pfad: ${this.path}");
csv()
.fromFile(csvFilePath)
.then((jsonObj)=>{
console.log(jsonObj);
})
},
/*
stop(){
console.log(`Stopping module helper: ${this.name}`);
},
*/
// handle messages from our module// each notification indicates a different messages
// payload is a data structure that is different per message.. up to you to design this
socketNotificationReceived(notification, payload) {
console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
// if config message from module
if (notification === "CONFIG") {
// save payload config info
this.config=payload
// wait 15 seconds, send a message back to module
setTimeout(()=> { this.sendSocketNotification("message_from_helper"," this is a test_message")}, 15000)
}
else if(notification === "????2") {
}
},
});
terminal says:
Unhandled rejection Error: File does not exist. Check to make sure the file path to your csv is correct.
at /home/dirk/MagicMirror/node_modules/csvtojson/v2/Converter.js:81:37
at suppressedCallback (fs.js:209:5)
at FSReqCallback.oncomplete (fs.js:153:23)
it’s from your SampleModule …
- how can i see the console.log statements in the browser, starting MM ?
- did i enter the code in the right place?
- if I enter the following into the terminal window:
node console.log (‘path: $ {this.path}’)
i got an error message:
bash: Syntaxerror unexpected word `(’
what am I doing wrong ?
many thanks in advance