• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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 error: Cannot find module 'envsub'

Scheduled Pinned Locked Moved Solved Troubleshooting
10 Posts 4 Posters 2.2k Views 4 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.
  • S Offline
    sdetweil @asd
    last edited by Apr 6, 2023, 8:10 PM

    @asd how did you upgrade?

    manual or scripted?

    if manual what commands did u enter?

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    A 1 Reply Last reply Apr 7, 2023, 9:10 AM Reply Quote 0
    • A Offline
      asd @sdetweil
      last edited by Apr 7, 2023, 9:10 AM

      @sdetweil thanks for your help.

      The MagicMirror was running well on git commit f14e956 from Feb, 7th 2023.
      When I upgraded via git pull within the ~/MagicMirror folder, the miror would not start anymore.

      Hence I tried to reverse the git pull via git reset --hard f14e956 which unfortunately did not help either.

      Besides this, I previously ran the standard apt update && upgrade -y. However, the mirror worked fine when restarting after this via pm2 restart mm. S o I do not think it was based of this.

      For reference, I run MM on a Raspberry Pi 4.

      S 1 Reply Last reply Apr 7, 2023, 10:26 AM Reply Quote 0
      • S Offline
        sdetweil @asd
        last edited by Apr 7, 2023, 10:26 AM

        @asd ok, got it.

        you forgot the second step of upgrade

        git pull && npm install

        you MUST run npm install

        and POSSIBLY. have to run npm install or electron-rebuild in all the installed modules
        due to the possible nodejs change and electron change.

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        A 1 Reply Last reply Apr 10, 2023, 7:25 PM Reply Quote 0
        • A Offline
          asd @sdetweil
          last edited by Apr 10, 2023, 7:25 PM

          @sdetweil awesome. It works again. Thank you very much. greatly appreciated!

          I have done my updates like this before and seem to have forgotten it this time.

          1 Reply Last reply Reply Quote 1
          • R Offline
            Roncham
            last edited by Apr 21, 2023, 2:00 AM

            I have the same problem. I updated using

            git pull && npm run install-mm
            

            I also ran npm install in each module, only 1 seemed to update. Rebooted and still get same error:

            @raspberrypi:~/MagicMirror $ npm run start
            
            > magicmirror@2.23.0 start
            > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js
            
            App threw an error during load
            Error: Cannot find module 'envsub'
            Require stack:
            - /home/pi/MagicMirror/js/app.js
            - /home/pi/MagicMirror/js/electron.js
            - /home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js
            - 
                at Module._resolveFilename (node:internal/modules/cjs/loader:963:15)
                at n._resolveFilename (node:electron/js2c/browser_init:2:109416)
                at Module._resolveFilename (/home/pi/MagicMirror/node_modules/module-alias/index.js:49:29)
                at Module._load (node:internal/modules/cjs/loader:811:27)
                at f._load (node:electron/js2c/asar_bundle:2:13328)
                at Module.require (node:internal/modules/cjs/loader:1035:19)
                at require (node:internal/modules/cjs/helpers:102:18)
                at Object.<anonymous> (/home/pi/MagicMirror/js/app.js:13:16)
                at Module._compile (node:internal/modules/cjs/loader:1141:14)
                at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
            A JavaScript error occurred in the main process
            Uncaught Exception:
            Error: Cannot find module 'envsub'
            Require stack:
            - /home/pi/MagicMirror/js/app.js
            - /home/pi/MagicMirror/js/electron.js
            - /home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js
            - 
                at Module._resolveFilename (node:internal/modules/cjs/loader:963:15)
                at n._resolveFilename (node:electron/js2c/browser_init:2:109416)
                at Module._resolveFilename (/home/pi/MagicMirror/node_modules/module-alias/index.js:49:29)
                at Module._load (node:internal/modules/cjs/loader:811:27)
                at f._load (node:electron/js2c/asar_bundle:2:13328)
                at Module.require (node:internal/modules/cjs/loader:1035:19)
                at require (node:internal/modules/cjs/helpers:102:18)
                at Object.<anonymous> (/home/pi/MagicMirror/js/app.js:13:16)
                at Module._compile (node:internal/modules/cjs/loader:1141:14)
                at Module._extensions..js (node:internal/modules/cjs/loader:1196:10)
            MESA-LOADER: failed to retrieve device information
            MESA-LOADER: failed to retrieve device information
            MESA-LOADER: failed to retrieve device information
            MESA-LOADER: failed to open kms_swrast: /usr/lib/dri/kms_swrast_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
            failed to load driver: kms_swrast
            MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: Permission denied (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri)
            failed to load swrast driver
            ^C/home/pi/MagicMirror/node_modules/electron/dist/electron exited with signal SIGINT
            

            Any other ideas?
            Thanks

            S 1 Reply Last reply Apr 21, 2023, 2:30 AM Reply Quote 0
            • S Offline
              sdetweil @Roncham
              last edited by Apr 21, 2023, 2:30 AM

              @Roncham I can only say that the npm run did not work

              from the MagicMirror folder do

              npm install --omit=dev
              

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              R H 2 Replies Last reply Apr 21, 2023, 2:38 AM Reply Quote 0
              • R Offline
                Roncham @sdetweil
                last edited by Apr 21, 2023, 2:38 AM

                @sdetweil said in Electron error: Cannot find module 'envsub':

                npm install --omit=dev

                That worked thank you!

                1 Reply Last reply Reply Quote 0
                • H Offline
                  hecaru @sdetweil
                  last edited by Apr 15, 2025, 1:17 PM

                  @sdetweil (posting it in case somebody else is going to need it)

                  In my case, the NPM error was:

                  npm ERR! code EBADENGINE
                  npm ERR! engine Unsupported engine
                  npm ERR! engine Not compatible with your version of node/npm: magicmirror@2.31.0
                  npm ERR! notsup Not compatible with your version of node/npm: magicmirror@2.31.0
                  npm ERR! notsup Required: {"node":">=22.14.0"}
                  npm ERR! notsup Actual:   {"npm":"8.19.4","node":"v16.20.2"}
                  

                  MagicMirror 2.31.0 needs at least Node 22, but through APT command, the Raspbian repos go up to 16. To solve this, I installed N, the Node version manager as an NPM module, then udpated Node that way.

                  $ sudo npm install -g n
                  
                  added 1 package, and audited 2 packages in 2s
                  
                  $ sudo n 22
                  
                    installing : node-v22.14.0
                         mkdir : /usr/local/n/versions/node/22.14.0
                         fetch : https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-armv7l.tar.xz
                       copying : node/22.14.0
                     installed : v22.14.0 (with npm 10.9.2)
                  
                  Note: the node command changed location and the old location may be remembered in your current shell.
                           old : /usr/bin/node
                           new : /usr/local/bin/node
                  If "node --version" shows the old version then start a new shell, or reset the location hash with:
                  hash -r  (for bash, zsh, ash, dash, and ksh)
                  rehash   (for csh and tcsh)
                  
                  $ node -v
                  v16.20.2
                  $ hash -r
                  $ node -v
                  v22.14.0
                  

                  Then rerun npm run install-mm and it will work.

                  Hope it helps. :)

                  S 1 Reply Last reply Apr 15, 2025, 1:21 PM Reply Quote 0
                  • S Offline
                    sdetweil @hecaru
                    last edited by Apr 15, 2025, 1:21 PM

                    @hecaru yes, and IF you use my upgrade script, it will handle that for you…

                    same place as the install script

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    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 Sam, technical setup by Karsten.
                    This forum is using NodeBB as its core | Contributors
                    Contact | Privacy Policy