Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dathbe opened this issue Mar 24, 2024 · 3 comments
Open

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

dathbe opened this issue Mar 24, 2024 · 3 comments

Comments

@dathbe
Copy link

dathbe commented Mar 24, 2024

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
Copy link
Owner

I've been waiting for just such ideas 🚀!

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! 😃

Thank you very much!

@dathbe
Copy link
Author

dathbe commented Mar 26, 2024

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

@KristjanESPERANTO
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants