MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    Module ignoring node_helper.js?

    Development
    2
    3
    2010
    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
      mjtice last edited by

      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
      • mochman
        mochman Module Developer last edited by mochman

        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
          mjtice last edited by

          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
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy