mgcrea / homebridge-tydom

Homebridge plugin to manage Tydom hardware by Delta Dore from Apple HomeKit.
62 stars 13 forks source link

Error [ERR_REQUIRE_ESM]: require() of ES Module #80

Closed kali8183 closed 2 years ago

kali8183 commented 2 years ago

Hello, since i moved from old homebridge version ( marcoraddatz/homebridge-docker) to newer one (oznu/docker-homebridge) i can't install tydom plugin anymore, i got this error :

ERROR LOADING PLUGIN homebridge-tydom: [1/27/2022, 10:52:45 AM] Error [ERR_REQUIRE_ESM]: require() of ES Module /homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/node_modules/chalk/source/index.js from /homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js not supported. Instead change the require of index.js in /homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:26:33) at Object.<anonymous> (/homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/lib/index.js:24:31) at Object.<anonymous> (/homebridge/node_modules/homebridge-tydom/lib/controller.js:9:24) at Object.<anonymous> (/homebridge/node_modules/homebridge-tydom/lib/platform.js:7:38) at Object.<anonymous> (/homebridge/node_modules/homebridge-tydom/lib/index.js:8:36) at Plugin.load (/usr/local/lib/node_modules/homebridge/lib/plugin.js:135:108) at PluginManager.initializeInstalledPlugins (/usr/local/lib/node_modules/homebridge/lib/pluginManager.js:64:30) at async Server.start (/usr/local/lib/node_modules/homebridge/lib/server.js:106:9)

Please can you help me ?

mgcrea commented 2 years ago

Looks like you might have pulled chalk@5 which is currently a pure ESM module and broken.

Can you check the version in /homebridge/node_modules/homebridge-tydom/node_modules/tydom-client/node_modules/chalk/package.json?

kali8183 commented 2 years ago

Bonjour, merci pour la réponse rapide, je viens de voir que tu étais français, ça sera plus simple pour moi.

Alors oui je te confirme que la version de chalk est bien 5.0.0

Du coup comment faire ?

Quitsoon commented 2 years ago

Hi,

I'm aslo facing this issue while importing a homebridge backup from a working configuration.

Chalk version is also 5.0.0 the package.json

[1/30/2022, 3:40:06 PM] ==================== [1/30/2022, 3:40:06 PM] ERROR LOADING PLUGIN homebridge-tydom: [1/30/2022, 3:40:06 PM] Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/node_modules/chalk/source/index.js from /usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js not supported. Instead change the require of index.js in /usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:26:33) at Object.<anonymous> (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/index.js:24:31) at Object.<anonymous> (/usr/lib/node_modules/homebridge-tydom/lib/controller.js:9:24) at Object.<anonymous> (/usr/lib/node_modules/homebridge-tydom/lib/platform.js:7:38) at Object.<anonymous> (/usr/lib/node_modules/homebridge-tydom/lib/index.js:8:36) at Plugin.load (/usr/lib/node_modules/homebridge/lib/plugin.js:135:108) at PluginManager.initializeInstalledPlugins (/usr/lib/node_modules/homebridge/lib/pluginManager.js:64:30) at async Server.start (/usr/lib/node_modules/homebridge/lib/server.js:106:9) [1/30/2022, 3:40:06 PM] ====================

Quitsoon commented 2 years ago

I took a look at my old installation and was able to see that :

In both installation chalk located in /homebridge-tydom/node_modules/tydom-client/node_modules/chalk/package.json shows 4.1.2

But in my working installation there is no "node_module" folder in /homebridge-tydom/node_modules/tydom-client/ so no chalk to be shown.

I just copy and paste the "homebridge-tydom" folder from my old installation to my new one and this is working for me.

Quitsoon commented 2 years ago

I tried to replicate the issue, I was able to show the error again. I tried to remove the "node_module" folder from /homebridge-tydom/node_modules/tydom-client/ but another error then arise : [1/30/2022, 5:27:44 PM] [Tydom] Failed to connect to Tydom hostname=mediation.tydom.com with username="001A25XXXXXX" [1/30/2022, 5:27:44 PM] SyntaxError: The URL's protocol must be one of "ws:", "wss:", or "ws+unix:" at initAsClient (/usr/lib/node_modules/homebridge-tydom/node_modules/ws/lib/websocket.js:692:17) at new WebSocket (/usr/lib/node_modules/homebridge-tydom/node_modules/ws/lib/websocket.js:84:7) at /usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:79:28 at new Promise (<anonymous>) at TydomClient.connect (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:77:16) at TydomController.connect (/usr/lib/node_modules/homebridge-tydom/lib/controller.js:54:13) at TydomPlatform.didFinishLaunching (/usr/lib/node_modules/homebridge-tydom/lib/platform.js:39:9)

hope this could help understand, I would love too but still limited understanding of that.

Neo33ASM commented 2 years ago

Exactement le même souci que notre ami @kali8183, et version 5 également pour le module chalk.

A noter que ça bloque complètement homebridge, obligé de désinstaller le module homebridge-tydom afin que ça fonctionne à nouveau.

MaksOuw commented 2 years ago

Idem ici, chalk v5 installé automatiquement (je passe par l'interface d'Homebridge pour gérer mes plugins habituellement, pas par le cli).

J'ai test de modifier à la main la version de Chalk dans les nodes_modules et de réinstaller, et je me prends une nouvelle erreur :

[1/31/2022, 5:22:53 PM] [Tydom] Failed to connect to Tydom hostname=mediation.tydom.com with username="<myUser>"
(node:433554) UnhandledPromiseRejectionWarning: SyntaxError: The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"
    at initAsClient (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/node_modules/ws/lib/websocket.js:692:17)
    at new WebSocket (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/node_modules/ws/lib/websocket.js:84:7)
    at /usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:79:28
    at new Promise (<anonymous>)
    at TydomClient.connect (/usr/lib/node_modules/homebridge-tydom/node_modules/tydom-client/lib/client.js:77:16)
    at TydomController.connect (/usr/lib/node_modules/homebridge-tydom/lib/controller.js:54:13)
    at TydomPlatform.didFinishLaunching (/usr/lib/node_modules/homebridge-tydom/lib/platform.js:39:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:433554) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:433554) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(j'ai remplacé mon user de connexion, j'ai bien un user en AXXXXXX).

La mise en place de leur nouveau système d'authentification a pas pété l'ancien système ? J'ai jamais fait attention à ça depuis que j'ai mis à jour.

mgcrea commented 2 years ago

Should be fixed with the latest 0.21.15 release.

kali8183 commented 2 years ago

Merci beaucoup ça fonctionne à nouveau avec la dernière version !