Read the statement by Michael Teeuw here.
Module ignoring node_helper.js?
-
I’m sure I’m missing something really obvious here… but I can’t see what it is. The contents of
MMM-HiWorld
print out just fine but the console logging innode_helper.js
never happens. As I understand it (from reading some other forum posts) I need to initializenode_helper.js
via a call instart: function()
?MMM-HiWorld.js:
$ cat MMM-HiWorld.js Module.register("MMM-HiWorld",{ // Default module config. // Default module config. defaults: { text: "Hi World!", animationSpeed: 1000, }, start: function() { this.sendSocketNotification('Starting'); var self = this; setInterval(function() { self.updateDom(); // no speed defined, so it updates instantly. }, 1000); //perform every 1000 milliseconds. }, // Override dom generator. getDom: function() { var wrapper = document.createElement("div"); wrapper.innerHTML = this.config.text; return wrapper; }, });
node_helper.js:
$ cat node_helper.js var NodeHelper = require('node_helper'); module.exports = NodeHelper.create({ start: function() { console.log('Starting node_helper'); }, socketNotificationReceived: function(notification, payload) { console.log('Okay, I got a notification.'); }, });
This is Raspbian Jessie (Raspberry Pi 2) and node v6.9.2.
Thanks!
-
node_helper.js doesn’t output
console.log()
to the same place theMMM-HiWorld.js
does. You’ll see the log pop up in the npm output. You can see the data when you runnpm start
on the raspberry pi. If you are using pm2 to autostart Magic Mirror, you can ssh into your pi and run
tail -f ~/.pm2/logs/mm-out-0.log
to see the console messages. You can also runtail -f ~/.pm2/logs/mm-error-0.log
to see all of your node_helper.js errors. -
Wow, thanks @mochman! Now that you mention it that makes perfect sense because
node_helper.js
isn’t executed on the client-end (right?).