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

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    (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: Error: Cannot find module

      Diese Meldung vom Editor kann man ignorieren.
      Wenn node-fetch in der Konfiguration auch noch in der Zeile darunter eingetragen wird, sollte die Meldung verschwinden.

      Bild_2021-09-13_112233.png

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

        @paul53 Das ist aber ne Meldung beim Ausführen.

        @ice987 Gab es nen Fehler im Log, nachdem du das Modul eingetragen hast? Das klingt mir schwer nach nicht installiert. Außerdem, was gibt folgender Befehl auf der Konsole aus?

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

          @paul53
          Module sind wie folgt eingetragen:
          57692e82-75bf-4cf4-9d83-93a9ba5f484c-image.png

          kompletter Fehler wie folgt:

          11:28:54.183	info	javascript.2 (855) Stop script script.js.08_Wetterstation.Skript_1
          11:28:54.182	info	javascript.1 (178) Stop script script.js.08_Wetterstation.Skript_1
          11:28:54.217	info	javascript.0 (171) Stop script script.js.08_Wetterstation.Skript_1
          11:28:54.295	info	javascript.2 (855) Start javascript script.js.08_Wetterstation.Skript_1
          11:28:54.304	error	javascript.2 (855) script.js.08_Wetterstation.Skript_1: Error: Cannot find module '/opt/iobroker/node_modules/iobroker.javascript/lib/../../node-fetch'
          11:28:54.305	error	javascript.2 (855) at script.js.08_Wetterstation.Skript_1:1:15
          11:28:54.306	error	javascript.2 (855) at script.js.08_Wetterstation.Skript_1:2:3
          11:28:54.306	info	javascript.2 (855) script.js.08_Wetterstation.Skript_1: registered 0 subscriptions and 0 schedules
          

          ich versuche mal ob's trotzdem funktioniert

          @AlCalzone

          cd /opt/iobroker
          npm ls node-fetch
          

          gibt:

          root@iobroker-v510:/opt/iobroker# cd /opt/iobroker
          root@iobroker-v510:/opt/iobroker# npm ls node-fetch
          iobroker.inst@2.0.3 /opt/iobroker
          └─┬ iobroker.javascript@5.2.8
            └── UNMET DEPENDENCY node-fetch@^3.0.0
          
          npm ERR! missing: node-fetch@^3.0.0, required by iobroker.javascript@5.2.8
          root@iobroker-v510:/opt/iobroker#
          
          paul53 1 Reply Last reply Reply Quote 0
          • 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
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            786
                                            Online

                                            31.8k
                                            Users

                                            80.0k
                                            Topics

                                            1.3m
                                            Posts

                                            5
                                            39
                                            3318
                                            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