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

Errors starting up #81

Closed
mwkrieger opened this issue Feb 1, 2022 · 8 comments
Closed

Errors starting up #81

mwkrieger opened this issue Feb 1, 2022 · 8 comments

Comments

@mwkrieger
Copy link

Hi Mike.

After last night's update, I did an npm install and now the MM won't start. In the logs I'm getting the below.

I tried removing the module and cloning a fresh copy, but it still won't load. Any insights?

[01.02.2022 12:23.02.197] [LOG] Module helper loaded: MMM-Remote-Control
[01.02.2022 12:23.02.281] [ERROR] App threw an error during load
[01.02.2022 12:23.02.283] [ERROR] Error [ERR_REQUIRE_ESM]: require() of ES Module /home/pi/MagicMirror/modules/MMM-Powerwall/node_modules/node-fetch/src/index.js from /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js not supported.
Instead change the require of index.js in /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js to a dynamic import() which is available in all CommonJS modules.
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (/home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js:10:15)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at loadModule (/home/pi/MagicMirror/js/app.js:127:19)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at Class.loaded (/home/pi/MagicMirror/js/node_helper.js:18:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at Class.loaded (/home/pi/MagicMirror/js/node_helper.js:18:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at loadModules (/home/pi/MagicMirror/js/app.js:176:3)
at /home/pi/MagicMirror/js/app.js:225:4
at loadConfig (/home/pi/MagicMirror/js/app.js:81:4)
at App.start (/home/pi/MagicMirror/js/app.js:212:3)
at Object. (/home/pi/MagicMirror/js/electron.js:153:7)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at loadApplicationPackage (/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js:110:16)
at Object. (/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js:222:9)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (node:electron/js2c/browser_init:193:3197)
at Object../lib/browser/init.ts (node:electron/js2c/browser_init:193:3401)
at webpack_require (node:electron/js2c/browser_init:1:128)
at node:electron/js2c/browser_init:1:1200
at node:electron/js2c/browser_init:1:1267
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
[01.02.2022 12:23.02.293] [ERROR] Whoops! There was an uncaught exception...
[01.02.2022 12:23.02.310] [ERROR] Error [ERR_REQUIRE_ESM]: require() of ES Module /home/pi/MagicMirror/modules/MMM-Powerwall/node_modules/node-fetch/src/index.js from /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js not supported.
Instead change the require of index.js in /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js to a dynamic import() which is available in all CommonJS modules.
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (/home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js:10:15)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at loadModule (/home/pi/MagicMirror/js/app.js:127:19)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at Class.loaded (/home/pi/MagicMirror/js/node_helper.js:18:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at Class.loaded (/home/pi/MagicMirror/js/node_helper.js:18:3)
at loadModule (/home/pi/MagicMirror/js/app.js:144:6)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at /home/pi/MagicMirror/js/app.js:167:6
at loadModule (/home/pi/MagicMirror/js/app.js:146:4)
at loadNextModule (/home/pi/MagicMirror/js/app.js:165:5)
at loadModules (/home/pi/MagicMirror/js/app.js:176:3)
at /home/pi/MagicMirror/js/app.js:225:4
at loadConfig (/home/pi/MagicMirror/js/app.js:81:4)
at App.start (/home/pi/MagicMirror/js/app.js:212:3)
at Object. (/home/pi/MagicMirror/js/electron.js:153:7)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at loadApplicationPackage (/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js:110:16)
at Object. (/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js:222:9)
at Function.c._load (node:electron/js2c/asar_bundle:5:13331)
at Object. (node:electron/js2c/browser_init:193:3197)
at Object../lib/browser/init.ts (node:electron/js2c/browser_init:193:3401)
at webpack_require (node:electron/js2c/browser_init:1:128)
at node:electron/js2c/browser_init:1:1200
at node:electron/js2c/browser_init:1:1267
at Function.c._load (node:electron/js2c/asar_bundle:5:13331) {
code: 'ERR_REQUIRE_ESM'
}
[01.02.2022 12:23.02.327] [ERROR] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?

@mwkrieger
Copy link
Author

Config file is as follows:
XXXXX is private info that I took out, but I've verified the actual values.
{
module: 'MMM-Powerwall',
position: 'middle_center',
header: '',
config: {
powerwallIP: 'XXXXX',
teslaAPIUsername: 'XXXXX,
graphs: [
'PowerwallSelfPowered',
'SolarProduction',
'HouseConsumption',
'EnergyBar',
'PowerLine',
'Grid',
'CarCharging'
],
powerwallPassword: 'XXXXXX'
}
}

@mwkrieger
Copy link
Author

Further up in the error log I see this as well.

Module helper loaded: MMM-Remote-Control
[01.02.2022 12:42.29.146] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/pi/MagicMirror/modules/MMM-Powerwall/node_modules/node-fetch/src/index.js from /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js not supported.
Instead change the require of index.js in /home/pi/MagicMirror/modules/MMM-Powerwall/node_helper.js to a dynamic import() which is available in all CommonJS modules.

@gonzo-256
Copy link

i too am running into this... it appears to be related to MagicMirrorOrg/MagicMirror#2649. I haven't had a chance to debug it yet, but hopefully one of us has luck here.

@gonzo-256
Copy link

@mwkrieger @MikeBishop

ok.... i think i may have fixed it... inmodules/MMM-Powerwall/node_helper.js update the fetch from require() to import()
const NodeHelper = require("node_helper");
const fs = require("fs").promises;
const fetch = import("node-fetch");
const powerwall = require("./powerwall");
const path = require("path");
const nunjucks = require("./../../vendor/node_modules/nunjucks");
const { check, validationResult, matchedData } = require('express-validator');
const bodyParser = require('./../../node_modules/body-parser');
const spawn = require("await-spawn");
const mqtt = require("async-mqtt");
const mutex = require("async-mutex").Mutex;

after doing that, i did an npm install (probably redundant), and npm start worked just fine

@MikeBishop
Copy link
Owner

Thanks! I've been off for a while and missed this issue, but I'll take a look in the next few days.

@MikeBishop
Copy link
Owner

It doesn't seem to be quite that simple, but there is a one-line change that lets the helper load properly. However, it looks like all modules are failing to communicate with their helpers, so it's likely to be a more general problem with my MM install at this point.

@gonzo-256
Copy link

Agreed. I have other modules fail and just removed them from my view.

@MikeBishop
Copy link
Owner

MikeBishop commented Feb 21, 2022

Okay, I think I've found the failing module in my install, and the one-line change I had before does fix this module with that one disabled. I've pushed 1f7abde directly to master since this was broken for people. Please reopen if that doesn't address it.

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

3 participants