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 'node-fetch' error with multiple MM modules

    Scheduled Pinned Locked Moved Solved Troubleshooting
    12 Posts 5 Posters 5.2k 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.
    • B Offline
      blackbull
      last edited by

      Hi,

      I have several failing with the “Cannot find module ‘node-fetch’” error. (see trace below)
      I have seen this with similar other (older) modules, and sadly I have not been able to fix this.

      https://github.com/alonsourbano/publika
      https://github.com/ZakarFin/mm-hsl-timetable
      https://github.com/cSharpBastard/mmm-nordic-electrical-spot-prices

      Browsing the forums, there seems to be similar issues with other modules after the MM 2.25.0 version.

      Things tried (which I can recall):

      • npm install of that missing ‘node-fetch’
        https://forum.magicmirror.builders/topic/15778/fix-for-black-screen-in-2-16-and-later?page=1
      • Fresh MM installations with Node.js version 20
        https://github.com/nodesource/distributions
      • downgrading to Node.js version 18

      All with similar results. Any advice appreciated, thanks!

      Respectfully,
      Saku

      > magicmirror@2.25.0 start
      > DISPLAY="${DISPLAY:=:0}" ./node_modules/.bin/electron js/electron.js
      
      [05.10.2023 22:14.53.083] [LOG]   Starting MagicMirror: v2.25.0
      [05.10.2023 22:14.53.090] [LOG]   Loading config ...
      [05.10.2023 22:14.53.092] [DEBUG] config template file not exists, no envsubst
      [05.10.2023 22:14.53.097] [LOG]   Loading module helpers ...
      [05.10.2023 22:14.53.099] [LOG]   No helper found for module: alert.
      [05.10.2023 22:14.53.148] [LOG]   Initializing new module helper ...
      [05.10.2023 22:14.53.149] [LOG]   Module helper loaded: updatenotification
      [05.10.2023 22:14.53.150] [LOG]   No helper found for module: clock.
      [05.10.2023 22:14.53.151] [LOG]   No helper found for module: compliments.
      [05.10.2023 22:14.53.208] [LOG]   Initializing new module helper ...
      [05.10.2023 22:14.53.209] [LOG]   Module helper loaded: MMM-OpenWeatherMapForecast
      [05.10.2023 22:14.53.234] [ERROR] (node:7772) UnhandledPromiseRejectionWarning: Error: Cannot find module 'node-fetch'
      Require stack:
      - /home/saku/MagicMirror/modules/publika/node_helper.js
      - /home/saku/MagicMirror/js/app.js
      - /home/saku/MagicMirror/js/electron.js
      - /home/saku/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js
      - 
          at node:internal/modules/cjs/loader:1084:15
          at Function.<anonymous> (node:electron/js2c/browser_init:2:117500)
          at Module._resolveFilename (/home/saku/MagicMirror/node_modules/module-alias/index.js:49:29)
          at node:internal/modules/cjs/loader:929:27
          at Function._load (node:electron/js2c/asar_bundle:2:13327)
          at Module.require (node:internal/modules/cjs/loader:1150:19)
          at require (node:internal/modules/cjs/helpers:110:18)
          at Object.<anonymous> (/home/saku/MagicMirror/modules/publika/node_helper.js:3:15)
          at Module._compile (node:internal/modules/cjs/loader:1271:14)
          at Object..js (node:internal/modules/cjs/loader:1326:10)
          at Module.load (node:internal/modules/cjs/loader:1126:32)
          at node:internal/modules/cjs/loader:967:12
          at Function._load (node:electron/js2c/asar_bundle:2:13327)
          at Module.require (node:internal/modules/cjs/loader:1150:19)
          at require (node:internal/modules/cjs/helpers:110:18)
          at loadModule (/home/saku/MagicMirror/js/app.js:180:19)
      (Use `electron --trace-warnings ...` to show where the warning was created)
      
      
      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @blackbull
        last edited by

        @blackbull yes, I saw someone else with the same problem

        it was the node-fetch version

        do this

        npm install node-fetch@2
        

        Sam

        How to add modules

        learning how to use browser developers window for css changes

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

          @blackbull we remove node fetch from the magic mirror package on this release as we drop back to the integrated fetch that’s provided in node and in the electron browser unfortunately that breaks a bunch of modules.

          So you can either NPM install it in every module that needs it or you can an NPM install it in the base once for all the modules

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          B 1 Reply Last reply Reply Quote 0
          • B Offline
            blackbull @sdetweil
            last edited by

            @sdetweil

            Thanks for info and pointers! Did the NPM install in base, but ended into a new obstacle.

            BR,
            Saku

            [05.10.2023 22:47.23.542] [ERROR] (node:8355) UnhandledPromiseRejectionWarning: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/saku/MagicMirror/modules/publika/node_modules/node-fetch/src/index.js from /home/saku/MagicMirror/modules/publika/node_helper.js not supported.
            Instead change the require of index.js in /home/saku/MagicMirror/modules/publika/node_helper.js to a dynamic import() which is available in all CommonJS modules.
                at Function._load (node:electron/js2c/asar_bundle:2:13327)
                at Object.<anonymous> (/home/saku/MagicMirror/modules/publika/node_helper.js:3:15)
                at Function._load (node:electron/js2c/asar_bundle:2:13327)
                at loadModule (/home/saku/MagicMirror/js/app.js:180:19)
                at loadModules (/home/saku/MagicMirror/js/app.js:210:10)
                at async App.start (/home/saku/MagicMirror/js/app.js:258:3)
            (Use `electron --trace-warnings ...` to show where the warning was created)
            
            
            S 1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @blackbull
              last edited by

              @blackbull yes, I saw someone else with the same problem

              it was the node-fetch version

              do this

              npm install node-fetch@2
              

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              B 1 Reply Last reply Reply Quote 0
              • B Offline
                blackbull @sdetweil
                last edited by

                @sdetweil YES! Big thanks! :)

                That needed to be run in the specific module folder, installing that in MM base did not work.

                Respectfully,
                Saku

                M 1 Reply Last reply Reply Quote 0
                • B BEGreen87 referenced this topic on
                • M Offline
                  myayo001 @blackbull
                  last edited by

                  @blackbull j’ai le meme soucis. quand tu dis le dossier spécifique du module, c’est par exemple dans MMM-moonraker ou dans MMM-moonraker/node_modules?

                  Merci d’avance.

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

                    @myayo001 did you see this above

                    https://forum.magicmirror.builders/post/111396

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    M bugsounetB 2 Replies Last reply Reply Quote 0
                    • M Offline
                      myayo001 @sdetweil
                      last edited by

                      @sdetweil oui j’ai vu le post je dois installer npm install node-fetch@2
                      je l’ai installer dans le dossier MMM-moonraker et j’ai toujours l’erreur

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

                        @sdetweil cela arrive quand la version principale de node est v10.x et que l’utilisateur demande la version v20 ou v22 avec la commande n

                        généralement resolu avec la version principale de node en v20. ensuite on peux utiliser n comme on a envie

                        M 1 Reply Last reply Reply Quote 0
                        • M Offline
                          myayo001 @bugsounet
                          last edited by

                          @bugsounet je n 'ai pas trop compris ce que je devais faire.
                          mais j’ai bien node v20

                          Mirror $ node -v

                          v20.18.1

                          KristjanESPERANTOK 1 Reply Last reply Reply Quote 0
                          • 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