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

node_helper tries to validate client JavaScript out browser context #267

Open
1 task done
jalibu opened this issue Aug 30, 2021 · 0 comments
Open
1 task done

node_helper tries to validate client JavaScript out browser context #267

jalibu opened this issue Aug 30, 2021 · 0 comments

Comments

@jalibu
Copy link

jalibu commented Aug 30, 2021

OS

any

NodeJS Version

14.17.x

MagicMirror Version

2.16.0

Remote Control Version

2.3.6

Did you try using just Remote Control alone with MM?

  • I have and the error still happening

Description

In the node_helper's loadModuleDefaultConfig() function is a require statement, which loads each module's main JavaScript file.
As these JavaScript files are executed in the browser, they may contain global variables such as "window". As this does not exist in the Node.js context, this module prints a ReferenceError.

I'd recommend to reduce the severity of the catched Error message to INFO or WARN (not ERROR), as it does not effect runtime stability.
Please also consider to find another, more robust way to parse MM modules.

Expected behavior

Appropriate severity logging
No parser errors on require()

Current behavior

see above

Possible solution

No response

Steps to reproduce

  1. Install MMM-RAIN-MAP (or any other module that references browser objects) next to MMM-Remote-Control
  2. Start MagicMirror
  3. Check logs

Log

[30.08.2021 22:25.33.102] [ERROR] ERROR! Could not validate main module js file.
[30.08.2021 22:25.33.106] [ERROR] ReferenceError: window is not defined
    at eval (webpack://mmm-rain-map/./node_modules/leaflet/dist/leaflet-src.js?:226:19)
    at eval (webpack://mmm-rain-map/./node_modules/leaflet/dist/leaflet-src.js?:7:11)
    at eval (webpack://mmm-rain-map/./node_modules/leaflet/dist/leaflet-src.js?:9:2)
    at Object../node_modules/leaflet/dist/leaflet-src.js (/Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:119)
    at __webpack_require__ (/Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:488355)
    at eval (webpack://mmm-rain-map/./src/client/Client.ts?:12:11)
    at Object../src/client/Client.ts (/Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:471167)
    at __webpack_require__ (/Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:488355)
    at /Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:488437
    at Object.<anonymous> (/Users/me/git/MagicMirror/modules/MMM-RAIN-MAP/MMM-RAIN-MAP.js:1:488484)

config.js

modules: [
 {
  module: "MMM-RAIN-MAP",
  position: "bottom_center"
 },
 {
  module: "MMM-Remote-Control",
  position: "bottom_left",
  disabled: false,
  config: {
   customCommand: {},
   customMenu: "custom_menu.json",
   showModuleApiMenu: true
  }
 }
]

Additional info

No response

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

No branches or pull requests

2 participants