From 08f8a5107a675d5b16b47ad06b4ff6f83541fe83 Mon Sep 17 00:00:00 2001 From: sam detweiler Date: Tue, 13 Feb 2024 00:02:02 -0700 Subject: [PATCH] add error message if config.js appears empty after loading w require() in app.js (#3383) from forum, https://forum.magicmirror.builders/topic/18493/node_helper-js-is-not-working user created own config.js, did not copy the module exports line.. this caused the js/defaults.js list of modules to be processed for node_helpers but the physical config.js to be loaded for the web page (hard coded in index.html) so user modules needing node_helper didn't have that .. this adds a warning message in npm start output to help user resolve.. took two days to debug without message --- CHANGELOG.md | 1 + js/app.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d8fb8dc..d14032a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ _This release is scheduled to be released on 2024-04-01._ - Ignore all custom css files (#3359) - [newsfeed] Fix newsfeed stall issue introduced by #3336 (#3361) - Changed `log.debug` to `log.log` in `app.js` where logLevel is not set because config is not loaded at this time (#3353) +- added message in case where config.js is missing the module.export line PR #3383 ### Deleted diff --git a/js/app.js b/js/app.js index ec8f42f3..77d0dc20 100644 --- a/js/app.js +++ b/js/app.js @@ -115,6 +115,9 @@ function App () { try { fs.accessSync(configFilename, fs.F_OK); const c = require(configFilename); + if (Object.keys(c).length === 0) { + Log.error("WARNING! Config file appears empty, maybe missing module.exports last line?"); + } checkDeprecatedOptions(c); return Object.assign(defaults, c); } catch (e) {