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.

    Add JS Code to the Mirror

    Scheduled Pinned Locked Moved Solved Troubleshooting
    33 Posts 5 Posters 15.4k Views 5 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.
    • D Offline
      dnj0104 @sdetweil
      last edited by

      @sdetweil

      then I got

      [2020-10-23 23:46:08.836] [INFO]   Checking file...  /home/pi/MagicMirror/config/config.js
      [2020-10-23 23:46:09.049] [INFO]   Your configuration file doesn't contain syntax errors :)
      
      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @dnj0104
        last edited by sdetweil

        @dnj0104 ok, so the error that causes the default config to load is caused by some other problem.

        missing module, or some other failure

        can u show the MM startup messages (from the window where you do npm start)

        a module consists of the folder name

        MMM-MPD
        

        and its main js file

        MMM-MPD.js
        

        and inside MMM-MPD.js is the module register statement

        Module.register("MMM-MPD", {
        

        and in config.js

          {
             module: 'MMM-MPD',
        

        this causes MM to look for the folder, filename and file contents in that order

        SO, it SOUNDS like from a prior post, that the REAL name is

        mod_client
        

        (so there must be the right folder name, file name and file contents of
        mod_client

        if so, you can rename the folder (mv is the rename command on linux)
        then in config.js you need

          module:'mod_client',
        

        see the topic ‘How to add modules’ in my signature

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • D Offline
          dnj0104
          last edited by

          @sdetweil said in Add JS Code to the Mirror:

          mod_client

          errors folder and file config.js (mmm-mpd) renamed to mod:

          [2020-10-24 00:03:42.600] [ERROR]  WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: ReferenceError: NodeHelper is not defined
              at Object.<anonymous> (/home/pi/MagicMirror/modules/mod_client/node_helper.js:4:18)
              at Module._compile (internal/modules/cjs/loader.js:786:30)
              at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
              at Module.load (internal/modules/cjs/loader.js:645:32)
              at Function.Module._load (internal/modules/cjs/loader.js:560:12)
              at Module.require (internal/modules/cjs/loader.js:685:19)
              at require (internal/modules/cjs/helpers.js:16:16)
              at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
              at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
              at /home/pi/MagicMirror/js/app.js:171:6
          [2020-10-24 00:03:42.601] [LOG]    Loading module helpers ...
          [2020-10-24 00:03:42.602] [LOG]    No helper found for module: alert.
          [2020-10-24 00:03:42.603] [LOG]    Initializing new module helper ...
          [2020-10-24 00:03:42.604] [LOG]    Module helper loaded: updatenotification
          [2020-10-24 00:03:42.605] [LOG]    No helper found for module: clock.
          [2020-10-24 00:03:42.616] [LOG]    Initializing new module helper ...
          [2020-10-24 00:03:42.617] [LOG]    Module helper loaded: calendar
          [2020-10-24 00:03:42.618] [LOG]    No helper found for module: .
          [2020-10-24 00:03:42.619] [LOG]    No helper found for module: currentweather.
          [2020-10-24 00:03:42.620] [LOG]    No helper found for module: weatherforecast.
          [2020-10-24 00:03:42.621] [LOG]    Initializing new module helper ...
          [2020-10-24 00:03:42.621] [LOG]    Module helper loaded: newsfeed
          [2020-10-24 00:03:42.623] [ERROR]  App threw an error during load
          [2020-10-24 00:03:42.625] [ERROR]  ReferenceError: NodeHelper is not defined
              at Object.<anonymous> (/home/pi/MagicMirror/modules/mod_client/node_helper.js:4:18)
              at Module._compile (internal/modules/cjs/loader.js:786:30)
              at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
              at Module.load (internal/modules/cjs/loader.js:645:32)
              at Function.Module._load (internal/modules/cjs/loader.js:560:12)
              at Module.require (internal/modules/cjs/loader.js:685:19)
              at require (internal/modules/cjs/helpers.js:16:16)
              at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
              at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
              at /home/pi/MagicMirror/js/app.js:171:6
          [2020-10-24 00:03:42.627] [ERROR]  Whoops! There was an uncaught exception...
          [2020-10-24 00:03:42.628] [ERROR]  ReferenceError: NodeHelper is not defined
              at Object.<anonymous> (/home/pi/MagicMirror/modules/mod_client/node_helper.js:4:18)
              at Module._compile (internal/modules/cjs/loader.js:786:30)
          

          ------result---- dark—screen electron just showed black----------

          roll back, Folder named to mod-client and in config.js and mpd_client.js to mod_client.
          Result; electron start with no error all my modules shows, but not mod_client aka mpd_client

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @dnj0104
            last edited by

            @dnj0104 what MM version are you running on? this problem was fixed in 2.10
            do this
            from the MM folder

            cd ~/MagicMirror
            git checkout modules/node_modules/node_helper/index.js
            

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • D Offline
              dnj0104
              last edited by

              I got version 20.13.0

              from your git command i get output

              pi@raspberrypi:~/MagicMirror $ git checkout modules/node_modules/node_helper/index.js
              error: pathspec 'modules/node_modules/node_helper/index.js' did not match any file(s) known to git
              
              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @dnj0104
                last edited by

                @dnj0104 can you do

                cd ~/MagicMirror
                grep version package.json
                

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                S 1 Reply Last reply Reply Quote 0
                • D Offline
                  dnj0104
                  last edited by

                  yes and and result is

                  pi@raspberrypi:~/MagicMirror $ grep version package.json
                  	"version": "2.13.0",
                  
                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @sdetweil
                    last edited by

                    @dnj0104 yeh, mess

                    this module should be installed like this to make up for the name problem

                    cd ~/ MagicMirror/modules
                    git clone https://github.com/timjong93/MMM-MPD.git mpd_client
                    cd mpd_client
                    npm install
                    

                    then everything matches

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    D 1 Reply Last reply Reply Quote 0
                    • S Offline
                      sdetweil @dnj0104
                      last edited by

                      @dnj0104 thanks… so the git checkout would not have worked, sorry…

                      try the install as I suggest above

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        dnj0104 @sdetweil
                        last edited by

                        @sdetweil

                        so then i throw mpd client folder in trash and follow your
                        install instructions?

                        because I believe there have been a problem when I first installed mpd_client, I did not been clear where the npm install should been placed, if you read in mpd-client readme.md maybe you understand, english is not my first language, and my linux-fu is below first grade :)

                        S 1 Reply Last reply Reply Quote 0
                        • S Offline
                          sdetweil @dnj0104
                          last edited by sdetweil

                          @dnj0104 is ok, he didn’t do the instructions correctly…

                          yes, start over

                          cd ~/MagicMirror/modules
                          rm -rf mod_client
                          

                          then do the install as I suggested

                          Sam

                          How to add modules

                          learning how to use browser developers window for css changes

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            dnj0104
                            last edited by

                            and then change folder name to mod-client ?

                            is it mod-client (folder) and mod_client in config.js in config array. do I also change name in mpd-client.js file?

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              sdetweil @dnj0104
                              last edited by

                              @dnj0104 everythign should be named mpd_client

                              look at the files list in the module
                              https://github.com/timjong93/MMM-MPD

                              all mpd_client

                              no, do NOT change the folder name, change the config.js to match

                              module: 'mpd_client',
                              

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              D 1 Reply Last reply Reply Quote 0
                              • D Offline
                                dnj0104 @sdetweil
                                last edited by

                                @sdetweil said in Add JS Code to the Mirror:

                                mpd_client

                                ok then

                                fresh install and download after your instructions:

                                [[ERROR]  WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: ReferenceError: NodeHelper is not defined
                                    at Object.<anonymous> (/home/pi/MagicMirror/modules/mpd_client/node_helper.js:4:18)
                                    at Module._compile (internal/modules/cjs/loader.js:786:30)
                                    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
                                    at Module.load (internal/modules/cjs/loader.js:645:32)
                                    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
                                    at Module.require (internal/modules/cjs/loader.js:685:19)
                                    at require (internal/modules/cjs/helpers.js:16:16)
                                    at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
                                    at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
                                    at /home/pi/MagicMirror/js/app.js:171:6
                                [2020-10-24 01:33:46.979] [LOG]    Loading module helpers ...
                                [2020-10-24 01:33:46.980] [LOG]    No helper found for module: alert.
                                [2020-10-24 01:33:46.981] [LOG]    Initializing new module helper ...
                                [2020-10-24 01:33:46.982] [LOG]    Module helper loaded: updatenotification
                                [2020-10-24 01:33:46.983] [LOG]    No helper found for module: clock.
                                [2020-10-24 01:33:46.984] [LOG]    Initializing new module helper ...
                                [2020-10-24 01:33:46.985] [LOG]    Module helper loaded: calendar
                                [2020-10-24 01:33:46.986] [LOG]    No helper found for module: .
                                [2020-10-24 01:33:46.988] [LOG]    No helper found for module: currentweather.
                                [2020-10-24 01:33:46.990] [LOG]    No helper found for module: weatherforecast.
                                [2020-10-24 01:33:46.991] [LOG]    Initializing new module helper ...
                                [2020-10-24 01:33:46.992] [LOG]    Module helper loaded: newsfeed
                                [2020-10-24 01:33:46.994] [ERROR]  App threw an error during load
                                [2020-10-24 01:33:47.003] [ERROR]  ReferenceError: NodeHelper is not defined
                                    at Object.<anonymous> (/home/pi/MagicMirror/modules/mpd_client/node_helper.js:4:18)
                                    at Module._compile (internal/modules/cjs/loader.js:786:30)
                                    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
                                    at Module.load (internal/modules/cjs/loader.js:645:32)
                                    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
                                    at Module.require (internal/modules/cjs/loader.js:685:19)
                                    at require (internal/modules/cjs/helpers.js:16:16)
                                    at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
                                    at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
                                    at /home/pi/MagicMirror/js/app.js:171:6
                                [2020-10-24 01:33:47.006] [ERROR]  Whoops! There was an uncaught exception...
                                [2020-10-24 01:33:47.007] [ERROR]  ReferenceError: NodeHelper is not defined
                                    at Object.<anonymous> (/home/pi/MagicMirror/modules/mpd_client/node_helper.js:4:18)
                                    at Module._compile (internal/modules/cjs/loader.js:786:30)
                                    at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
                                    at Module.load (internal/modules/cjs/loader.js:645:32)
                                    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
                                    at Module.require (internal/modules/cjs/loader.js:685:19)
                                    at require (internal/modules/cjs/helpers.js:16:16)
                                    at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
                                    at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
                                    at /home/pi/MagicMirror/js/app.js:171:6
                                [2020-10-24 01:33:47.014] [ERROR]  MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
                                [2020-10-24 01:33:47.014] [ERROR]  If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
                                [2020-10-24 01:33:49.707] [LOG]    Launching application.]
                                

                                something wrong with nodehelper I believe.

                                Or maybe I have wrong port and IP to my mpd.

                                S 1 Reply Last reply Reply Quote 0
                                • S Offline
                                  sdetweil @dnj0104
                                  last edited by

                                  @dnj0104 bad module,

                                  edit the node_helper.js
                                  and add this as the 1st line

                                  const NodeHelper = require("node_helper");
                                  

                                  Sam

                                  How to add modules

                                  learning how to use browser developers window for css changes

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    dnj0104
                                    last edited by

                                    I added your code snippet in 1st line after

                                    var mpd = require('mpd'),
                                    

                                    and output

                                    [2020-10-24 01:56:54.490] [ERROR]  WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: /home/pi/MagicMirror/modules/mpd_client/node_helper.js:1
                                    var mpd = require('mpd'),const NodeHelper = require("node_helper");
                                                             ^^^^^
                                    
                                    SyntaxError: Unexpected token const
                                        at Module._compile (internal/modules/cjs/loader.js:722:23)
                                        at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
                                        at Module.load (internal/modules/cjs/loader.js:645:32)
                                        at Function.Module._load (internal/modules/cjs/loader.js:560:12)
                                        at Module.require (internal/modules/cjs/loader.js:685:19)
                                        at require (internal/modules/cjs/helpers.js:16:16)
                                        at loadModule (/home/pi/MagicMirror/js/app.js:134:17)
                                        at loadNextModule (/home/pi/MagicMirror/js/app.js:169:5)
                                        at /home/pi/MagicMirror/js/app.js:171:6
                                        at Class.loaded (/home/pi/MagicMirror/js/node_helper.js:18:3)
                                    
                                    S 1 Reply Last reply Reply Quote 0
                                    • S Offline
                                      sdetweil @dnj0104
                                      last edited by

                                      @dnj0104 no, I want it to be a line BEFORE the stuff in the file already

                                      Sam

                                      How to add modules

                                      learning how to use browser developers window for css changes

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        dnj0104
                                        last edited by

                                        AH! Sorry!

                                        Changed it now your snippet in 1st Line

                                        And we have Success!!! Finally!!

                                        Thanks Alot @sdetweil

                                        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
                                        • 2
                                        • 2 / 2
                                        • 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