KristjanESPERANTO / MagicMirror-3rd-Party-Modules

This project provides an overview of all MagicMirror² modules and puts the modules through a few tests.
https://kristjanesperanto.github.io/MagicMirror-3rd-Party-Modules/
MIT License
13 stars 4 forks source link

Consistency check so Remote-Control does not throw errors #21

Open dathbe opened 3 months ago

dathbe commented 3 months ago

One of the things that I've noticed is that the MMM-Remote-Control module will throw errors on some modules even though the modules themselves work fine. As two examples, the Remote Control module does not seem to like the way the MMM-OpenWeatherMapForecast module has a quasi-circular reference in defining defaults (within the defaults section, it defines one variable, and then calls back to that same variable later in the defaults):

0|mm  | [24.03.2024 13:45.49.602] [ERROR] 2024-03-24T13:45:49 <error> ERROR! Could not validate main module js file. (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:320 Class.loadModuleDefaultConfig)
0|mm  | [24.03.2024 13:45.49.650] [ERROR] 2024-03-24T13:45:49 <error> ReferenceError: defaults is not defined
0|mm  |     at Object.<anonymous> (/home/pi/MagicMirror/modules/MMM-OpenWeatherMapForecast/MMM-OpenWeatherMapForecast.js:80:22)
0|mm  |     at Module._compile (node:internal/modules/cjs/loader:1271:14)
0|mm  |     at Object..js (node:internal/modules/cjs/loader:1326:10)
0|mm  |     at Module.load (/home/pi/MagicMirror/modules/MMM-MyScoreboard/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
0|mm  |     at node:internal/modules/cjs/loader:967:12
0|mm  |     at Function._load (node:electron/js2c/asar_bundle:2:13327)
0|mm  |     at Module.require (node:internal/modules/cjs/loader:1150:19)
0|mm  |     at require (node:internal/modules/cjs/helpers:121:18)
0|mm  |     at Class.loadModuleDefaultConfig (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:314:30)
0|mm  |     at /home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:268:26
0|mm  |     at FSReqCallback.oncomplete (node:fs:211:5)
0|mm  |  (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:321 Class.loadModuleDefaultConfig)

And it does not seem to like the MMM-Rain-Map module either, though I'm less clear on why:

0|mm  | [24.03.2024 13:45.53.759] [ERROR] 2024-03-24T13:45:53 <error> ERROR! Could not load main module js file. Error found: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/pi/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js from /home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js not supported.
0|mm  | MMM-RAIN-MAP.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
0|mm  | Instead rename MMM-RAIN-MAP.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/pi/MagicMirror/modules/MMM-RAIN-MAP/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
0|mm  |  (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:323 Class.loadModuleDefaultConfig)

It would be great if this project (nice work, by the way, much easier to search and see modules here than on the MM wiki) was able to flag such errors for developers.

Thanks!

KristjanESPERANTO commented 3 months ago

I've been waiting for just such ideas :rocket:!

I still have to read up on the first problem, but I at least have an idea of how I could check the second, but I have to test whether it works. I'll put it on my to-do list! :smiley:

Thank you very much!

dathbe commented 3 months ago

Thanks. Feel free to close the issue if you want. I won't close it in case you want it as a reminder.

KristjanESPERANTO commented 3 months ago

Yes, let's leave it open as a reminder.