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.

    Cannot find module 'undici' - 'npm install' doesn't work

    Scheduled Pinned Locked Moved Solved Troubleshooting
    17 Posts 3 Posters 8.5k 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.
    • S Offline
      sdetweil @Klinge
      last edited by sdetweil

      @Klinge yes it says we need node 20.18.1 or above
      https://forum.magicmirror.builders/topic/19271/version-2-30-0-requires-updated-nodejs-warning-for-pi0w-installations

      anyhow quickest way
      install tool to allow changing node versions

      sudo npm install n -g
      sudo n 20.18.1
      

      now do the MagicMirror install

      cd ~/MagicMirror
      npm run install-mm 
      

      Sam

      How to add modules

      learning how to use browser developers window for css changes

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

        @Klinge also, next time use my upgrade script

        https://github.com/sdetweil/MagicMirror_scripts

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        K 1 Reply Last reply Reply Quote 0
        • K Offline
          Klinge @sdetweil
          last edited by

          @sdetweil Thank you for your help.

          After updating to 20.18.1 unfortunately I get the following error

          pi@raspberrypi:~/MagicMirror $ pwd
          /home/pi/MagicMirror
          pi@raspberrypi:~/MagicMirror $ npm run install-mm
          node: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by node)
          

          And yes, the next time I will use your upgrade script ;-)

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

            @Klinge you are on buster os… you need to upgrade to a later version, as that library is not available on buster… my script would have told you that…

            use my backup/restore scripts
            https://github.com/sdetweil/MagicMirror-backup-restore

            to be able to quickly move to new OS

            use install script to install MM on new os
            https://github.com/sdetweil/MagicMirror_scripts
            and then restore to put back MM config and modules

            (and upgrade script next time)

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            K 1 Reply Last reply Reply Quote 0
            • K Offline
              Klinge @sdetweil
              last edited by

              @sdetweil Shit, that’s the same problem I had with my second mirror a few weeks ago. Well, it’s been running fine since 2016.
              Many thanks for your tips. With your scripts I’ll quickly install the new one.

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

                @Klinge if you had started w my script it would have told you so you didn’t have to upgrade NOW . sorry

                the whole objective of my scripts is to prevent this exact scenario. broke system.

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                K 1 Reply Last reply Reply Quote 0
                • K Offline
                  Klinge @sdetweil
                  last edited by

                  @sdetweil Yes, you’re absolutely right, of course. Sometimes you have to learn from your own mistakes ;-) so we just call it a Layer8 problem ;-) Thanks anyway for your effort

                  1 Reply Last reply Reply Quote 1
                  • K Klinge has marked this topic as solved on
                  • K Klinge has marked this topic as unsolved on
                  • K Offline
                    Klinge
                    last edited by

                    Hi,
                    @sdetweil some minutes ago I updated my MMM with your script

                    kling@raspi-mm-gaeste:~/MagicMirror $ bash -c  "$(curl -sL https://raw.githubusercontent.com/sdetweil/MagicMirror_scripts/master/upgrade-script.sh)" apply
                    update log will be in /home/kling/MagicMirror/installers/upgrade.log
                    doing test run = false
                    Node currently installed. Checking version number.
                    Minimum Node version: v20.18.1
                    Installed Node version: v20.9.0
                    installing correct version of node and npm, please wait
                    Check current Node installation ...
                    Node currently installed. Checking version number.
                    Minimum Node version: v20.18.1
                    Installed Node version: v20.18.1
                    No Node.js upgrade necessary.
                    Check current NPM installation ...
                    NPM currently installed. Checking version number.
                    Minimum npm version: V10.8.2
                    Installed npm version: V10.8.2
                    No npm upgrade necessary.
                    
                    want /var/swap=200MByte, checking existing: keeping it
                    saving custom.css
                    local version 2.30.0 already same as master 2.30.0
                    restoring custom.css
                    
                    

                    After that I tried to start my MMM and now I got the same error message "Cannot find module ‘undici’.

                    kling@raspi-mm-gaeste:~/MagicMirror $ display=:0 npm start
                    
                    > magicmirror@2.30.0 start
                    > npm run start:x11
                    
                    
                    > magicmirror@2.30.0 start:x11
                    > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js
                    
                    [2025-02-13 16:04:02.858] [ERROR] App threw an error during load 
                    [2025-02-13 16:04:02.863] [ERROR] Error: Cannot find module 'undici'
                    Require stack:
                    - /home/kling/MagicMirror/js/app.js
                    - /home/kling/MagicMirror/js/electron.js
                        at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
                        at s._resolveFilename (node:electron/js2c/browser_init:2:121498)
                        at Module._resolveFilename (/home/kling/MagicMirror/node_modules/module-alias/index.js:49:29)
                        at Module._load (node:internal/modules/cjs/loader:1058:27)
                        at c._load (node:electron/js2c/node_init:2:17025)
                        at Module.require (node:internal/modules/cjs/loader:1318:19)
                        at require (node:internal/modules/helpers:179:18)
                        at Object.<anonymous> (/home/kling/MagicMirror/js/app.js:15:40)
                        at Module._compile (node:internal/modules/cjs/loader:1484:14)
                        at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
                        at Module.load (node:internal/modules/cjs/loader:1295:32)
                        at Module._load (node:internal/modules/cjs/loader:1111:12)
                        at c._load (node:electron/js2c/node_init:2:17025)
                        at Module.require (node:internal/modules/cjs/loader:1318:19)
                        at require (node:internal/modules/helpers:179:18)
                        at Object.<anonymous> (/home/kling/MagicMirror/js/electron.js:4:14) 
                    A JavaScript error occurred in the main process
                    Uncaught Exception:
                    Error: Cannot find module 'undici'
                    Require stack:
                    - /home/kling/MagicMirror/js/app.js
                    - /home/kling/MagicMirror/js/electron.js
                        at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
                        at s._resolveFilename (node:electron/js2c/browser_init:2:121498)
                        at Module._resolveFilename (/home/kling/MagicMirror/node_modules/module-alias/index.js:49:29)
                        at Module._load (node:internal/modules/cjs/loader:1058:27)
                        at c._load (node:electron/js2c/node_init:2:17025)
                        at Module.require (node:internal/modules/cjs/loader:1318:19)
                        at require (node:internal/modules/helpers:179:18)
                        at Object.<anonymous> (/home/kling/MagicMirror/js/app.js:15:40)
                        at Module._compile (node:internal/modules/cjs/loader:1484:14)
                        at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
                        at Module.load (node:internal/modules/cjs/loader:1295:32)
                        at Module._load (node:internal/modules/cjs/loader:1111:12)
                        at c._load (node:electron/js2c/node_init:2:17025)
                        at Module.require (node:internal/modules/cjs/loader:1318:19)
                        at require (node:internal/modules/helpers:179:18)
                        at Object.<anonymous> (/home/kling/MagicMirror/js/electron.js:4:14)
                    [5112:0213/160403.943167:ERROR:gbm_wrapper.cc(74)] Failed to get fd for plane.: No such file or directory (2)
                    [5112:0213/160403.943531:ERROR:gbm_wrapper.cc(257)] Failed to export buffer to dma_buf: No such file or directory (2)
                    
                    

                    So my question again, what did I wrong? It is necessary to install the MMM completely new?

                    Thank you.

                    Kind regards.
                    Klinge

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

                      @Klinge you tried to do it manually , my script will NOT upgrade OVER the same version accidentally

                      local version 2.30.0 already same as master 2.30.0

                      so you have to FORCE it

                      change the update command string end from
                      apply
                      to
                      force

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      K 1 Reply Last reply Reply Quote 0
                      • K Offline
                        Klinge @sdetweil
                        last edited by

                        @sdetweil Great, now it works.

                        Thank you for your help again

                        1 Reply Last reply Reply Quote 1
                        • K Klinge has marked this topic as solved on
                        • T Offline
                          tleo32
                          last edited by

                          Hello - I am receiving a similar error and struggling to resolve. Does anyone have suggestions?

                          npm error code EBADENGINE
                          npm error engine Unsupported engine
                          npm error engine Not compatible with your version of node/npm: magicmirror@2.30.0
                          npm error notsup Not compatible with your version of node/npm: magicmirror@2.30.0
                          npm error notsup Required: {“node”:“>=20.18.1 <21 || >=22”}
                          npm error notsup Actual: {“npm”:“10.8.1”,“node”:“v20.16.0”}
                          npm error A complete log of this run can be found in: /home/tleonetti/.npm/_logs/2025-02-17T00_47_21_325Z-debug-0.log

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

                            @tleo32 yes, you didnt read the release notes. we need node 20.18.1 or above, not 21

                            because you started manually, use my upgrade script w force as the parm instead of apply

                            see https://github.com/sdetweil/MagicMirror_scripts
                            also https://forum.magicmirror.builders/post/123993

                            Sam

                            How to add modules

                            learning how to use browser developers window for css changes

                            T 1 Reply Last reply Reply Quote 0
                            • T Offline
                              tleo32 @sdetweil
                              last edited by

                              thank you for responding @sdetweil, for some reason not updating the node, please see below:

                              update log will be in /home/tleonetti/MagicMirror/installers/upgrade.log
                              doing test run = false
                              Node currently installed. Checking version number.
                              Minimum Node version: v20.18.1
                              Installed Node version: v20.16.0
                              installing correct version of node and npm, please wait
                              Check current Node installation …
                              Node currently installed. Checking version number.
                              Minimum Node version: v20.18.1
                              Installed Node version: v20.16.0
                              Node should be upgraded.
                              Installing Node.js …
                              force: line 323: [: too many arguments
                              tar (child): /home/tleonetti/node_release-.tar.gz: Cannot open: No such file or directory
                              tar (child): Error is not recoverable: exiting now
                              tar: Child returned status 2
                              tar: Error is not recoverable: exiting now
                              node version is
                              Node.js installation Done! version=v20.16.0
                              Check current NPM installation …
                              NPM currently installed. Checking version number.
                              Minimum npm version: V10.8.2
                              Installed npm version: V10.8.1
                              npm should be upgraded.
                              Installing npm …
                              npm installation Done! version=V10.8.1

                              upgrading from version 2.30.0 to 2.30.0
                              force: line 611: pm2: command not found
                              fetching latest revisions
                              updating MagicMirror runtime, please wait
                              npm error code EBADENGINE
                              npm error engine Unsupported engine
                              npm error engine Not compatible with your version of node/npm: magicmirror@2.30.0
                              npm error notsup Not compatible with your version of node/npm: magicmirror@2.30.0
                              npm error notsup Required: {“node”:“>=20.18.1 <21 || >=22”}
                              npm error notsup Actual: {“npm”:“10.8.1”,“node”:“v20.16.0”}
                              npm error A complete log of this run can be found in: /home/tleonetti/.npm/_logs/2025-02-17T19_56_02_704Z-debug-0.log

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

                                @tleo32 can you do this

                                cd ~/MagicMirror
                                curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash - &>somefile.txt
                                

                                and send me somefile.txt via email. same userid at gmail

                                and then
                                short fix

                                sudo npm install n
                                sudo n 20.18.1
                                hash -r
                                npm run install-MagicMirror
                                

                                please advise results

                                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
                                  sdetweil @sdetweil
                                  last edited by

                                  @tleo32 I also pushed a fix, so, rerunning the upgrade with force should work…

                                  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
                                    sdetweil @sdetweil
                                    last edited by

                                    he had nvm
                                    installed too, conflicts with n ( nodejs version of nvm)

                                    Sam

                                    How to add modules

                                    learning how to use browser developers window for css changes

                                    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