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.

    Need "correct" version of node-libgpiod ....

    Scheduled Pinned Locked Moved Solved Troubleshooting
    22 Posts 3 Posters 701 Views 3 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.
    • R Offline
      rkorell @sdetweil
      last edited by rkorell

      @sdetweil Dear Sam,
      thanks for this information.
      Can you please enlighten me?
      I can read what you wrote and I got a light idea - but didn’t understand …

      I definitely have used your install script.
      what is @electron and
      what correlation is between node-libgpiod and @electron ? and what will this

      ../../node_modules/.bin/electron-rebuild
      

      do?

      Sorry for these questions - I would like to understand, what happens.

      If this is “neccessary” I will try to automate this for others with a postinstall script.
      Thanks for your effort!
      warmest regards,
      Ralf

      S 2 Replies Last reply Reply Quote 1
      • S Offline
        sdetweil @rkorell
        last edited by

        @rkorell javascript is compiled to a byteform by the nodejs engine

        there is one embedded inside electron and one outside,
        nodejs

        the bytecode has a version number.
        the engine needs the proper version to execute it
        like version 21 added a new instruction, but vers 20 engine cant execute it

        i dont know the version differences

        anyhow, the electron-rebuild application will rebuild the parts of the js code used in the node_helper to match the internal/embedded node engine inside electron

        because startup is using the electron app

        in server mode we use the mode app

        you should know if you run
        node serveronly, then the bytecode has to match the nodejs standalone engine version
        this is why we try to keep the nodejs/electron internal node versions the same
        (there is a node rebuild too)

        Sam

        How to add modules

        learning how to use browser developers window for css changes

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

          @rkorell here is the postinstall i provide for a couple modules

          #!/bin/bash
          
          base=~/MagicMirror
          logfile=/dev/null
          if [ ! -e $base/node_modules/@electron/rebuild ];  then 
              cd $base
              if [ -e $base/node_modules/.bin/electron-rebuild ]; then 
          	# remove the old version	  
                npm uninstall electron-rebuild >>$logfile 2>&1
              fi	  
              # install the new version 
              npm install @electron/rebuild >>$logfile 2>&1
              cd - >/dev/null
          fi
          
          $base/node_modules/.bin/electron-rebuild 
          

          they changed the name of the npm package

          but as i install it as part of install/upgrade
          its correct most of the time

          and in package.json, in the scripts section add

          "postinstall":"./postinstall"
          

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • R Offline
            rkorell @sdetweil
            last edited by

            @sdetweil said

            you should know if you run
            node serveronly, then the bytecode has to match the nodejs standalone engine version

            OK, thanks.
            It seems that rebuild have corrected the error for the module.
            When I try to run a node-command in the shell (terminal) then I get an similar error message as above.
            Is this caused by your explanation part above?
            Different versions needed for either terminal or inside mirror?
            Can you tell me HOW the magic mirror is started (when I have used your install script)?

            Is there a way to test something which had to run in the mirror (like the module) on commandline?

            To illustrate what I mean:
            I have a very short test-script test-gpiod.js

            // test-gpiod.js , Aug 2025, Dr. Ralf Korell
            const { Chip } = require("node-libgpiod");
            try {
              const chip = new Chip(0);
              console.log("Chip label:", chip.getChipLabel());
            } catch (err) {
              console.error("Error loading chip:", err);
            }
            

            which I try to run with

            node test-gpiod.js
            

            But this produces error message:

            /home/pi/MagicMirror/modules/MMM-PresenceScreenControl/node_modules/bindings/bindings.js:121
            throw e;
            ^
            
            Error: The module '/home/pi/MagicMirror/modules/MMM-PresenceScreenControl/node_modules/node-libgpiod/build/Release/node-libgpiod.node'
            was compiled against a different Node.js version using
            NODE_MODULE_VERSION 128. This version of Node.js requires
            NODE_MODULE_VERSION 115. Please try re-compiling or re-installing
            the module (for instance, using `npm rebuild` or `npm install`).
            at Module._extensions..node (node:internal/modules/cjs/loader:1586:18)
            at Module.load (node:internal/modules/cjs/loader:1288:32)
            at Module._load (node:internal/modules/cjs/loader:1104:12)
            at Module.require (node:internal/modules/cjs/loader:1311:19)
            at require (node:internal/modules/helpers:179:18)
            at bindings (/home/pi/MagicMirror/modules/MMM-PresenceScreenControl/node_modules/bindings/bindings.js:112:48)
            at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-PresenceScreenControl/node_modules/node-libgpiod/lib/misc.js:1:37)
            at Module._compile (node:internal/modules/cjs/loader:1469:14)
            at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
            at Module.load (node:internal/modules/cjs/loader:1288:32) {
            code: 'ERR_DLOPEN_FAILED'
            }
            
            Node.js v20.18.1
            

            Thanks for any help!
            Warmest regards,
            Ralf

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

              @rkorell MM is started by doing node --run or npm start or npm run start

              that matches a script in the scripts section of package.json

              the MagicMirror installed files support 3 different runtimes

              npm start - full using electron

              		"start:x11": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron  js/electron.js",
              

              npm run server - server mode only , using node engine

              		"server": "node ./serveronly",
              

              npm run client - UI mode using electron

              node clientonly --address 192.168.1.5 --port 8080
              

              which does this to launch electron, not it doesn’t use the module node_helpers, as its the UI portion
              only… the server side (under full, or server only) does that

              const child = require("node:child_process").spawn(electron, elecParams, options);
              

              as I said before, the electron embedded node engines CAN be different than the install standalone nodejs version

              node -v
              will tell you the standalone node js version.

              the problem you have, I mentioned in the prior post, if the node versions don’t match, then
              you MAY have to recompile when switching runtime choices…

              npm rebuild 
              

              will fix the standalone node version

              electron-rebuild
              

              will fix the electron version

              I believe the current electron version is 22, and the node version we require is 22

              this is because the standalone node version of 24 has dropped support for 32 bit runtimes… and knocks out using the
              32 bit legacy raspi OS images that some use…

              we put out a message to tell the versions when you start MM

              VERSIONS: electron: 36.6.0; used node: 22.15.0; installed node: 22.15.0; npm: 10.9.2; pm2: 6.0.8

              SO… fun times… keeping the node versions synched will avoid the problem you are encountering

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                rkorell @sdetweil
                last edited by

                @sdetweil
                Dear Sam, OK, thanks for this.
                Not fully understood…

                How can I

                1. figure out, how my mirror is started? (looooong ago I‘ve used your install script and (if I remember correctly) I‘ve answered „yes“ to „do you want automatically start your mirror at system startup“ - or something similar. - Never took care about, what is done - it worked (and still works)…)
                2. double check the above „VERSIONS“ - message - is this message in logfile?
                3. can I get „keeping the node versions synched“?

                Thanks for further advise!
                Warmest regards,
                Ralf

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

                  @rkorell 1. my pm2 setup uses the file

                  ~/MagicMirror/installers/mm.sh
                  

                  you can see that by using the

                  pm2 info xxxx
                  

                  command, where xxx is the name or number of the app row in

                  pm2 status 
                  

                  output, from my desktop , note you CAN setup the SAME NAMED app multiple times,
                  so the pm2 start app_name
                  might be ambiguous
                  so pm2 start 8 would target the app on line 8

                  ┌────┬─────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
                  │ id │ name                │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
                  ├────┼─────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
                  │ 8  │ MagicMirror         │ default     │ 2.32.0… │ fork    │ N/A      │ 0      │ 245… │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 7  │ MagicMirror 8       │ default     │ 2.31.0… │ fork    │ N/A      │ 0      │ 8    │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 6  │ MagicMirror1        │ default     │ 2.31.0… │ fork    │ N/A      │ 0      │ 13   │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 0  │ Smart Mirror        │ default     │ 0.0.30  │ fork    │ N/A      │ 0      │ 31   │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 2  │ checkarec           │ default     │ N/A     │ fork    │ 2870     │ 19D    │ 0    │ online    │ 0%       │ 3.4mb    │ sam      │ disabled │
                  │ 5  │ smart-mirror        │ default     │ 0.0.31  │ fork    │ N/A      │ 0      │ 8    │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 4  │ smart-mirror ttt    │ default     │ 0.0.30  │ fork    │ N/A      │ 0      │ 10   │ stopped   │ 0%       │ 0b       │ sam      │ disabled │
                  │ 3  │ start_alexa_bk      │ default     │ N/A     │ fork    │ 2871     │ 19D    │ 0    │ online    │ 0%       │ 2.4mb    │ sam      │ disabled │
                  │ 1  │ startspot           │ default     │ N/A     │ fork    │ 6315     │ 19D    │ 439  │ online    │ 0%       │ 2.5mb    │ sam      │ disabled │
                  │ 9  │ testups             │ default     │ N/A     │ fork    │ 2885     │ 19D    │ 0    │ online    │ 0%       │ 3.2mb    │ sam    
                  

                  using pm2, you can view the log with

                  pm2 logs yyy --lines=xxxx
                  

                  yyy is the name or number of the app from status above), if not supplied,
                  output from all managed apps is displayed, 1 after the others

                  xxxx is the count of most recent lines to display (default 15)

                  you can also see the files(.out and .err, by app) in the

                  ~/.pm2/logs
                  

                  folder

                  MM puts out a messages at runtime (this from my desktop system)

                  [2025-08-09 09:47:38.743] [INFO]  System information:
                  ### SYSTEM:   manufacturer: System manufacturer; model: System Product Name; virtual: false
                  ### OS:       platform: linux; distro: Ubuntu; release: 22.04.5 LTS; arch: x64; kernel: 5.15.0-144-generic
                  ### VERSIONS: electron: 36.6.0; used node: 22.15.0; installed node: 22.15.0; npm: 10.9.2; pm2: 6.0.8
                  ### OTHER:    timeZone: America/Chicago; ELECTRON_ENABLE_GPU: undefined 
                  

                  notice the versions line

                  keep the node versions synced… yes manually (I use the nodejs version of nvm, called n )
                  if installed this will show the versions installed

                  n list
                  

                  and

                  n
                  

                  will show the list AND the current one, but you have to type q to exit the list
                  (because n updates the /usr/local/bin folder, you have to use sudo to actually install or change the active version)

                  or
                  if you use my install/upgrade script they will make sure the correct standalone version is installed

                  my scripts install and use n if needed to change versions

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  R 1 Reply Last reply Reply Quote 0
                  • R Offline
                    rkorell @sdetweil
                    last edited by rkorell

                    @sdetweil Dear Sam,
                    thanks again for this long explanation!

                    My versions (if I interpret correctly) doesn’t mismatch :-(

                    0|MagicMir | ### SYSTEM:   manufacturer: ; model: ; virtual: false
                    0|MagicMir | ### OS:       platform: linux; distro: Debian GNU/Linux; release: 12; arch: arm64; kernel: 6.12.20+rpt-rpi-2712
                    0|MagicMir | ### VERSIONS: electron: 32.2.7; used node: 20.18.1; installed node: 20.18.1; npm: 10.8.2; pm2: 5.4.3
                    0|MagicMir | ### OTHER:    timeZone: Europe/Berlin; ELECTRON_ENABLE_GPU: undefined 
                    

                    So I’m not sure at all, what to do.

                    pi@MagicMirrorPi5:~ $ n list
                    node/20.18.1
                    
                    

                    Does show up exact this version, as well.
                    Where are my problems from ???
                    Thanks a LOT for any idea!

                    Ralf

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

                      @rkorell

                      so, if, in the module folder you do

                      npm rebuild
                      

                      it will fix the version to the standalone node engine

                      if you do

                      electron-rebuild
                      

                      it should fix the version to the electron embedded node engine

                      if the engine is the same, only one of those is required

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      R 2 Replies Last reply Reply Quote 0
                      • R Offline
                        rkorell @sdetweil
                        last edited by

                        @sdetweil OK; thanks.
                        I will stop to handle these mismatches.
                        Will try to get the MM-Module runnable .
                        Console/terminal runs with node may not be necessary …
                        Thanks anyway for your kind support!
                        Ralf

                        1 Reply Last reply Reply Quote 1
                        • 1
                        • 2
                        • 3
                        • 2 / 3
                        • 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