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.5k 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

      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
      • mochmanM Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            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