Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. (gelöst) NPM-Modul "node-fetch" in der Javascript-Instanz

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    (gelöst) NPM-Modul "node-fetch" in der Javascript-Instanz

    This topic has been deleted. Only users with topic management privileges can see it.
    • paul53
      paul53 @ice987 last edited by paul53

      @ice987 sagte:

      npm ERR! missing: node-fetch@^3.0.0, required by iobroker.javascript@5.2.8
      

      Dann wurde es offenbar nicht installiert: Noch mal versuchen und die Log-Ausgabe beobachten.

      Du solltest nicht als root unterwegs sein.

      ice987 1 Reply Last reply Reply Quote 0
      • ice987
        ice987 @paul53 last edited by ice987

        @paul53

        hab' ich:

        root@iobroker-v510:/opt/iobroker# npm ls node-fetch
        iobroker.inst@2.0.3 /opt/iobroker
        ├─┬ iobroker.javascript@5.2.8
        │ └── node-fetch@3.0.0  deduped
        └── node-fetch@3.0.0
        

        mit v3.x gibt's einige Änderungen: https://github.com/node-fetch/node-fetch/blob/HEAD/docs/v3-UPGRADE-GUIDE.md.
        require funktioniert offenbar nicht mehr.

        paul53 AlCalzone 2 Replies Last reply Reply Quote 0
        • paul53
          paul53 @ice987 last edited by

          @ice987 sagte: hab' ich:

          Ich meinte: Aus der Konfiguration löschen, speichern und wieder eintragen - also noch mal die Installation versuchen.

          @ice987 sagte in NPM-Module in der Javascript instanz:

          require funktioniert offenbar nicht mehr.

          Ich binde alle Module mit require ein.

          ice987 1 Reply Last reply Reply Quote 1
          • ice987
            ice987 @paul53 last edited by

            @paul53

            This module was converted to be a ESM only package in version 3.0.0-beta.10. node-fetch is an ESM-only module - you are not able to import it with require. We recommend you stay on v2 which is built with CommonJS unless you use ESM yourself. We will continue to publish critical bug fixes for it.

            paul53 1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @ice987 last edited by paul53

              @ice987
              Gerade bei mir getestet:
              node-fetch wurde unter /opt/iobroker/node_modules/iobroker.javascript/node_modules installiert, require will aber unter /opt/iobroker/node_modules darauf zugreifen, wo es nicht installiert ist.

              ice987 1 Reply Last reply Reply Quote 0
              • ice987
                ice987 @paul53 last edited by

                @paul53 sagte in NPM-Module in der Javascript instanz:

                Ich meinte: Aus der Konfiguration löschen, speichern und wieder eintragen - also noch mal die Installation versuchen.

                nun funktioniert es!

                Vielen Dank!

                1 Reply Last reply Reply Quote 0
                • AlCalzone
                  AlCalzone Developer @ice987 last edited by

                  @ice987 sagte in (gelöst) NPM-Module in der Javascript instanz:

                  iobroker.inst@2.0.3 /opt/iobroker
                  ├─┬ iobroker.javascript@5.2.8
                  │ └── node-fetch@3.0.0  deduped
                  └── node-fetch@3.0.0
                  

                  Hast du zufällig node-fetch mal innerhalb /opt/iobrokerhändisch nachinstalliert?
                  Das sieht aus, als würde es auch in /opt/iobroker/package.json stehen, wo es definitiv nicht hingehört.

                  ice987 1 Reply Last reply Reply Quote 0
                  • ice987
                    ice987 @AlCalzone last edited by ice987

                    @alcalzone
                    leider ist das so, ja.

                    AlCalzone 1 Reply Last reply Reply Quote 0
                    • AlCalzone
                      AlCalzone Developer @ice987 last edited by

                      @ice987 Dann am besten mal entfernen, das dürfte nämlich die Ursache für solche Probleme sein.

                      cd /opt/iobroker
                      npm uninstall node-fetch
                      
                      ice987 1 Reply Last reply Reply Quote 0
                      • ice987
                        ice987 @AlCalzone last edited by ice987

                        @alcalzone

                        root@iobroker-v510:/opt/iobroker# cd /opt/iobroker
                        root@iobroker-v510:/opt/iobroker# npm uninstall node-fetch
                        npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
                        npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
                        
                        removed 19 packages and audited 1289 packages in 35.686s
                        
                        102 packages are looking for funding
                          run `npm fund` for details
                        
                        found 64 vulnerabilities (5 low, 21 moderate, 35 high, 3 critical)
                          run `npm audit fix` to fix them, or `npm audit` for details
                        root@iobroker-v510:/opt/iobroker# npm ls node-fetch
                        iobroker.inst@2.0.3 /opt/iobroker
                        └─┬ iobroker.javascript@5.2.8
                          └── node-fetch@3.0.0
                        

                        die "Zusätzlichen NPM-Module" im Javascript-Adapter wurden vorher entfernt und sind aktuell nicht drin. Ist die Installation so nun in Ordnung?

                        Das Skript scheint zu funktionieren...

                        AlCalzone 1 Reply Last reply Reply Quote 0
                        • AlCalzone
                          AlCalzone Developer @ice987 last edited by

                          @ice987 Das sieht besser aus. Wenn du solche Probleme künftig vermeiden willst, am besten noch all die anderen Pakete deinstallieren, die unnötigerweise in /opt/iobroker/package.json stehen. Da sollten ausschließlich dependencies drin sein, die mit iobroker. oder @iobroker/ beginnen.

                          Vorsichtshalber mal ein Backup vorher fahren 🙂

                          ice987 1 Reply Last reply Reply Quote 0
                          • ice987
                            ice987 @AlCalzone last edited by

                            @alcalzone
                            wunderbar!

                            hab' gerade gekuckt in /opt/iobroker/package.json: alles fängt mit iobroker. oder @iobroker/ an ausser:

                            "colors": "^1.3.3",
                            "fs-extra": "^7.0.1"
                            "iobroker": "^2.0.3",
                            "semver": "^5.6.0",
                            "yargs": "^7.0.2"
                            

                            alles stehen lassen?

                            AlCalzone 1 Reply Last reply Reply Quote 0
                            • AlCalzone
                              AlCalzone Developer @ice987 last edited by

                              @ice987 iobroker drin lassen. Der Rest dürfte raus können.

                              ice987 1 Reply Last reply Reply Quote 0
                              • ice987
                                ice987 @AlCalzone last edited by ice987

                                @alcalzone
                                ok, hab alles gelistete entfernt (ausser iobroker). Nun habe ich aber erneut das Problem mit dem Error:

                                Module sind wie folgt eingetragen:
                                c91a6e3b-8f85-42ea-9b8c-2bcc00fca5a2-image.png

                                error wie folgt:

                                14:52:47.875	error	javascript.2 (185) script.js.08_Wetterstation.082_Meteoblue: Error: Cannot find module '/opt/iobroker/node_modules/iobroker.javascript/lib/../../node-fetch'
                                
                                root@iobroker-v510:/opt/iobroker# npm ls node-fetch
                                iobroker.inst@2.0.3 /opt/iobroker
                                └─┬ iobroker.javascript@5.2.8
                                  └── node-fetch@3.0.0
                                
                                AlCalzone paul53 2 Replies Last reply Reply Quote 0
                                • AlCalzone
                                  AlCalzone Developer @ice987 last edited by

                                  @ice987 entferne es mal, starte den Adapter neu, dann füge es wieder hinzu.

                                  ice987 1 Reply Last reply Reply Quote 0
                                  • ice987
                                    ice987 @AlCalzone last edited by ice987

                                    @alcalzone
                                    ich habe alles hier
                                    31b0f607-d79f-4326-b9dd-dbb2c8fc8cd9-image.png
                                    entfernt, Instanz neu gestartet, der error bleibt. node-fetch wieder hinzugefügt, Instanz heu gestartet, Fehler bleibt.

                                    1 Reply Last reply Reply Quote 0
                                    • paul53
                                      paul53 @ice987 last edited by

                                      @ice987 sagte: error wie folgt:

                                      Wie ist es in das Skript eingebunden?

                                      ice987 1 Reply Last reply Reply Quote 0
                                      • ice987
                                        ice987 @paul53 last edited by ice987

                                        @paul53

                                        aktuell (zu Testzwecken) nur so:

                                        const fetch = require('node-fetch');
                                        

                                        welches bereits den Fehler ergibt:

                                        paul53 1 Reply Last reply Reply Quote 0
                                        • paul53
                                          paul53 @ice987 last edited by paul53

                                          @ice987
                                          require erwartet es im Verzeichnis /opt/iobroker/node_modules, wo es offenbar nicht (mehr) installiert ist.

                                          Error: Cannot find module '/opt/iobroker/node_modules/iobroker.javascript/lib/../../node-fetch'
                                          

                                          import reagiert anders.

                                          1 Reply Last reply Reply Quote 0
                                          • AlCalzone
                                            AlCalzone Developer last edited by AlCalzone

                                            Dann ist da im Adapter irgendwas faul...
                                            import wird unter der Haube in require umgeschrieben, sollte sich also gleich verhalten.

                                            @ice987 Probier mal als Workaround:

                                            cd /opt/iobroker/node_modules/iobroker.javascript
                                            npm install --production
                                            
                                            paul53 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            879
                                            Online

                                            31.7k
                                            Users

                                            79.6k
                                            Topics

                                            1.3m
                                            Posts

                                            5
                                            39
                                            3253
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo