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.

    electron-rebuild and MagicMirror v2.18 (and more)

    Scheduled Pinned Locked Moved Development
    40 Posts 16 Posters 24.8k Views 21 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.
    • bugsounetB Offline
      bugsounet Banned
      last edited by

      Hi, because (sometime) i’m kind

      I will offer you a tips for next release of MagicMirror (it’s comes 01/01/2022)

      Some modules need library linked to MagicMirror and do electron-rebuild step.

      • Last electron-rebuild package is actually not really ready for MagicMirror using (install many package not used)
      • Last package is not really ready for raspberry pi, and rebuild build will failed
        • problems with SSL
        • Problems with sub-dependencies (lzma-native can failed on build)

      So ?

      • I just write the new rebuild library dedicated to MagicMirror
      • I will maintened it (For my modules and yours if you want)
      • It will use exactly what MagicMirror needs (and ONLY that)
      • it will replace the electron-rebuild package

      What’s this new library ?

      • This library is magicmirror-rebuild
      • You can use it directly in your package.json file
        "dependencies": {
          "magicmirror-rebuild": "^1.0.0",
          ....
        }
      
      • You can install it directly with this command in a module directory:
      npm i magicmirror-rebuild
      
      • you can ask the rebuild step of MagicMirror (electron) with this command (in a module root directory)
      ./node_modules/.bin/MagicMirror-rebuild
      

      Sample with MagicMirror v2.18 and MMM-PIR-Sensor module

      bugsounet@debian:~/MagicMirror/modules/MMM-PIR-Sensor$ npm install
      npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
      npm WARN deprecated har-validator@5.1.5: this library is no longer supported
      npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
      
      > epoll@4.0.1 install /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll
      > node-gyp rebuild
      
      make : on entre dans le répertoire « /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build »
        CXX(target) Release/obj.target/epoll/src/epoll.o
        SOLINK_MODULE(target) Release/obj.target/epoll.node
        COPY Release/epoll.node
      make : on quitte le répertoire « /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build »
      
      > Magic-Mirror-Module-PIR-Sensor@1.1.0 postinstall /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor
      > electron-rebuild -e ../../node_modules/electron
      
      ⠋ Searching dependency tree
      An unhandled error occurred inside electron-rebuild
      Could not detect abi for version 16.0.5 and runtime electron.  Updating "node-abi" might help solve this issue if it is a new release of electron
      
      Error: Could not detect abi for version 16.0.5 and runtime electron.  Updating "node-abi" might help solve this issue if it is a new release of electron
          at Object.getAbi (/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/node-abi/index.js:36:9)
          at new Rebuilder (/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/electron-rebuild/lib/src/rebuild.js:126:48)
          at rebuildWithOptions (/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/electron-rebuild/lib/src/rebuild.js:404:23)
          at Object.doRebuild [as rebuild] (/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/electron-rebuild/lib/src/rebuild.js:427:16)
          at /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/electron-rebuild/lib/src/cli.js:124:33
          at Generator.next (<anonymous>)
          at fulfilled (/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/electron-rebuild/lib/src/cli.js:6:58)
      npm ERR! code ELIFECYCLE
      npm ERR! errno 255
      npm ERR! Magic-Mirror-Module-PIR-Sensor@1.1.0 postinstall: `electron-rebuild -e ../../node_modules/electron`
      npm ERR! Exit status 255
      npm ERR! 
      npm ERR! Failed at the Magic-Mirror-Module-PIR-Sensor@1.1.0 postinstall script.
      npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
      
      npm ERR! A complete log of this run can be found in:
      npm ERR!     /home/bugsounet/.npm/_logs/2021-12-23T12_20_03_436Z-debug.log
      

      So the result is failed !

      1. Let’s install magicmirror-rebuild library
      bugsounet@debian:~/MagicMirror/modules/MMM-PIR-Sensor$ npm i magicmirror-rebuild
      npm notice created a lockfile as package-lock.json. You should commit this file.
      + magicmirror-rebuild@1.0.3
      
      1. Now try to execute MagicMirror-rebuild script for rebuild
      bugsounet@debian:~/MagicMirror/modules/MMM-PIR-Sensor$ ./node_modules/.bin/MagicMirror-rebuild 
      ⠼ MagicMirror Building module: epoll, Completed: 0gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
      ⠴ MagicMirror Building module: epoll, Completed: 0gyp http GET https://www.electronjs.org/headers/v16.0.5/node-v16.0.5-headers.tar.gz
      ⠼ MagicMirror Building module: epoll, Completed: 0gyp http 200 https://www.electronjs.org/headers/v16.0.5/node-v16.0.5-headers.tar.gz
      ⠏ MagicMirror Building module: epoll, Completed: 0gyp http GET https://www.electronjs.org/headers/v16.0.5/SHASUMS256.txt
      ⠧ MagicMirror Building module: epoll, Completed: 0gyp http 200 https://www.electronjs.org/headers/v16.0.5/SHASUMS256.txt
      gyp info spawn /usr/bin/python3
      gyp info spawn args [
      gyp info spawn args   '/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/node_modules/node-gyp/gyp/gyp_main.py',
      gyp info spawn args   'binding.gyp',
      gyp info spawn args   '-f',
      gyp info spawn args   'make',
      gyp info spawn args   '-I',
      gyp info spawn args   '/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build/config.gypi',
      gyp info spawn args   '-I',
      gyp info spawn args   '/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/node_modules/node-gyp/addon.gypi',
      gyp info spawn args   '-I',
      gyp info spawn args   '/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/16.0.5/include/node/common.gypi',
      gyp info spawn args   '-Dlibrary=shared_library',
      gyp info spawn args   '-Dvisibility=default',
      gyp info spawn args   '-Dnode_root_dir=/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/16.0.5',
      gyp info spawn args   '-Dnode_gyp_dir=/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/node_modules/node-gyp',
      gyp info spawn args   '-Dnode_lib_file=/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/16.0.5/<(target_arch)/node.lib',
      gyp info spawn args   '-Dmodule_root_dir=/home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll',
      gyp info spawn args   '-Dnode_engine=v8',
      gyp info spawn args   '--depth=.',
      gyp info spawn args   '--no-parallel',
      gyp info spawn args   '--generator-output',
      gyp info spawn args   'build',
      gyp info spawn args   '-Goutput_dir=.'
      gyp info spawn args ]
      ⠋ MagicMirror Building module: epoll, Completed: 0gyp info spawn make
      gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
      make : on entre dans le répertoire « /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build »
        CXX(target) Release/obj.target/epoll/src/epoll.o
      ⠸ MagicMirror Building module: epoll, Completed: 0  SOLINK_MODULE(target) Release/obj.target/epoll.node
      ⠼ MagicMirror Building module: epoll, Completed: 0  COPY Release/epoll.node
      make : on quitte le répertoire « /home/bugsounet/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll/build »
      ✔ MagicMirror Rebuild Complete
      

      That you see MagicMirror Rebuild Complete !
      Your module is now installed correctly

      wishmaster270W C G LusbuebL 4 Replies Last reply Reply Quote 5
      • hedmikH Offline
        hedmik
        last edited by

        Wow, thanks for sharing this!!!
        Now, I’m back on track again :-)

        bugsounetB 1 Reply Last reply Reply Quote 0
        • wishmaster270W Offline
          wishmaster270 Module Developer @bugsounet
          last edited by

          @bugsounet Thanks for this lib. Integrated it into two of my modules yesterday because I couldn’t get them compiled with electron-rebuild.

          bugsounetB 1 Reply Last reply Reply Quote 0
          • bugsounetB Offline
            bugsounet Banned @wishmaster270
            last edited by

            @wishmaster270 :

            If it can help, it’s perfect ;)
            I have do the same too for rebuild modules

            but don’t forget to delete "electron-rebuild": "v.xxx", from for package.json file ;)
            because this old package is not needed now

            @bugsounet

            1 Reply Last reply Reply Quote 0
            • bugsounetB Offline
              bugsounet Banned @hedmik
              last edited by

              @hedmik : i just share (one of) my own library ;)

              1 Reply Last reply Reply Quote 0
              • C Offline
                cyber152 @bugsounet
                last edited by

                @bugsounet thank you very much, for weeks I am looking for a solution to finally be able to add an essential function to the mirror :thumbs_up:

                1 Reply Last reply Reply Quote 0
                • G Offline
                  gonzonia @bugsounet
                  last edited by

                  @bugsounet THANK YOU! This saved me a lot of headaches. I went ahead and updated to 2.18 and got the exact error you reference in the exact same module. A quick search and I found your very helpful solution. Thank you for sharing.

                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    lhops
                    last edited by

                    I get an error when " ~/node_modules $ ~/.bin/MagicMirror-rebuild"
                    error=(an unhandled error occurred inside electron-rebuild)
                    unable to find electron’s version number of MagicMirror etc

                    L bugsounetB 2 Replies Last reply Reply Quote 0
                    • L Offline
                      lhops @lhops
                      last edited by

                      @lhops
                      Can or has anyone written code for an new MMM-PIR-Sensor module that will work will the new version of MagicMirror. If not is that something that your can do? I wish I knew more about the code I would do it myself.

                      1 Reply Last reply Reply Quote 0
                      • bugsounetB Offline
                        bugsounet Banned @lhops
                        last edited by

                        @lhops said in electron-rebuild and MagicMirror v2.18 (and more):

                        I get an error when " ~/node_modules $ ~/.bin/MagicMirror-rebuild"

                        execute ./node_modules/.bin/MagicMirror-rebuild INSIDE the module directory ;)

                        not inside other directory ;)
                        Note :

                        1. every module in MagicMirror is there:
                        cd ~/MagicMirror/modules
                        
                        1. After change again the directory to your wanted module,
                          for MMM-PIR-Sensor module (for example):
                        cd MMM-PIR-Sensor
                        
                        1. after install magicmirror-rebuild
                        npm i magicmirror-rebuild
                        
                        1. execute MagicMirror-rebuild program
                        ./node_modules/.bin/MagicMirror-rebuild
                        
                        1. you will see MagicMirror Rebuild Complete

                        2. it’s done ;)

                        L 1 Reply Last reply Reply Quote 0
                        • L Offline
                          lhops @bugsounet
                          last edited by

                          @bugsounet
                          This is the results of the instructions:

                          pi@raspberrypi:~/MagicMirror/modules/MMM-PIR-Sensor $ npm i magicmirror-rebuild
                          npm ERR! code EJSONPARSE
                          npm ERR! path /home/pi/MagicMirror/modules/MMM-PIR-Sensor/package.json
                          npm ERR! JSON.parse Unexpected string in JSON at position 803 while parsing ‘{
                          npm ERR! JSON.parse “name”: "Magic-Mirror-Module-PIR-Sen’
                          npm ERR! JSON.parse Failed to parse JSON data.
                          npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.

                          npm ERR! A complete log of this run can be found in:
                          npm ERR! /home/pi/.npm/_logs/2022-01-10T14_40_47_069Z-debug-0.log

                          I am sure you can look at this and see my problem.
                          Thank you for all your help!

                          bugsounetB 1 Reply Last reply Reply Quote 0
                          • bugsounetB Offline
                            bugsounet Banned @lhops
                            last edited by bugsounet

                            @lhops said in electron-rebuild and MagicMirror v2.18 (and more):

                            npm ERR! JSON.parse “name”: "Magic-Mirror-Module-PIR-Sen’

                            If you have modified the “package.json” file … and you do not respect the syntax.
                            here is the result ;)
                            (Info: it is not like this that we rename a module)

                            to correct your issue try this:

                            cd ~/MagicMirror/modules/MMM-PIR-Sensor
                            rm -rf node_modules package-lock.json
                            git reset --hard HEAD
                            npm install magicmirror-rebuild --save
                            npm remove electron-rebuild
                            npm install
                            

                            (Sometime, i’m very kind… So kind for me)

                            @bugsounet

                            L 1 Reply Last reply Reply Quote 0
                            • L Offline
                              lhops @bugsounet
                              last edited by

                              @bugsounet
                              That did the trick. How can I thank you. It is working like it should!!

                              bugsounetB 1 Reply Last reply Reply Quote 0
                              • bugsounetB Offline
                                bugsounet Banned @lhops
                                last edited by

                                I have open this PR (Pull Request) for commit this change with MagicMirror-rebuild to @paviro to accept it (or not)

                                S 1 Reply Last reply Reply Quote 0
                                • S Offline
                                  susl @bugsounet
                                  last edited by

                                  @bugsounet I followed your instructions but the rebuilding step failed with the following message:

                                  MagicMirror Building module: epoll, Completed: 0gyp: name ‘openssl_fips’ is not defined while evaluating condition ‘openssl_fips != “”’ in binding.gyp while trying to load binding.gyp
                                  ✖ MagicMirror Rebuild Failed

                                  An unhandled error occurred inside electron-rebuild
                                  node-gyp failed to rebuild ‘/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll’.
                                  Error: gyp failed with exit code: 1

                                  Error: node-gyp failed to rebuild ‘/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/epoll’.
                                  Error: gyp failed with exit code: 1

                                  at ModuleRebuilder.rebuildNodeGypModule (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/build/module-rebuilder.js:193:19)
                                  at processTicksAndRejections (node:internal/process/task_queues:96:5)
                                  at async Rebuilder.rebuildModuleAt (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/build/rebuild.js:180:9)
                                  at async Rebuilder.rebuild (/home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/build/rebuild.js:143:17)
                                  at async /home/pi/MagicMirror/modules/MMM-PIR-Sensor/node_modules/magicmirror-rebuild/build/cli.js:141:9

                                  Do you know what the problem is? Thanks!

                                  bugsounetB 1 Reply Last reply Reply Quote 0
                                  • bugsounetB Offline
                                    bugsounet Banned @susl
                                    last edited by

                                    @susl :

                                    • Recommended version of npm: v6.14.15
                                    • Recommended version of node: v14.x.x or v16.x.x

                                    to verify, try this in a terminal (or ssh):

                                    node -v
                                    npm -v
                                    
                                    S 1 Reply Last reply Reply Quote 0
                                    • S Offline
                                      susl @bugsounet
                                      last edited by

                                      @bugsounet
                                      node version: v17.3.0
                                      npm version: 8.3.0

                                      So obviously not the correct version :-( Do you know how I can change the versions?

                                      S 1 Reply Last reply Reply Quote 0
                                      • S Do not disturb
                                        sdetweil @susl
                                        last edited by

                                        @susl you can use n to install or select different versions of node (and npm)
                                        to install n
                                        sudo npm install n -g
                                        then to install or use a version of node
                                        n 16

                                        to switch

                                        n

                                        the select from the list

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

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

                                          @sdetweil
                                          Thanks a lot. I works now!

                                          1 Reply Last reply Reply Quote 0
                                          • cowboysdudeC Offline
                                            cowboysdude Module Developer
                                            last edited by

                                            @bugsounet Thank you for this!! It works like a charm ;)

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