• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Module ignoring node_helper.js?

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 2.3k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    mjtice
    last edited by Dec 25, 2016, 2:57 PM

    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 in node_helper.js never happens. As I understand it (from reading some other forum posts) I need to initialize node_helper.js via a call in start: 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!

    1 Reply Last reply Reply Quote 0
    • M Offline
      mochman Module Developer
      last edited by mochman Dec 25, 2016, 3:12 PM Dec 25, 2016, 3:12 PM

      node_helper.js doesn’t output console.log() to the same place the MMM-HiWorld.js does. You’ll see the log pop up in the npm output. You can see the data when you run npm 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 run tail -f ~/.pm2/logs/mm-error-0.log to see all of your node_helper.js errors.

      1 Reply Last reply Reply Quote 3
      • M Offline
        mjtice
        last edited by Dec 25, 2016, 3:35 PM

        Wow, thanks @mochman! Now that you mention it that makes perfect sense because node_helper.js isn’t executed on the client-end (right?).

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          2/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy