{"record":{"id":"18fda78376ef32b0","repo":"MagicMirrorOrg/MagicMirror","slug":"could-not-load-watchtargets-from-config","errorCode":null,"errorMessage":"Could not load watchTargets from config.","messagePattern":"Could not load watchTargets from config\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"serveronly/watcher.js","lineNumber":253,"sourceCode":"\t\t\t: path.join(rootDir, target);\n\n\t\t// Check if file exists\n\t\tif (!fs.existsSync(targetPath)) {\n\t\t\tLog.warn(`Watch target does not exist: ${targetPath}`);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if it's a file (directories are not supported)\n\t\tconst stats = fs.statSync(targetPath);\n\t\tif (stats.isFile()) {\n\t\t\twatchFile(targetPath);\n\t\t} else {\n\t\t\tLog.warn(`Watch target is not a file (directories not supported): ${targetPath}`);\n\t\t}\n\t}\n} catch {\n\t// Config file might not exist or be invalid, use fallback targets\n\tLog.warn(\"Could not load watchTargets from config.\");\n}\n\nprocess.on(\"SIGINT\", () => {\n\tisShuttingDown = true;\n\tif (restartTimer) clearTimeout(restartTimer);\n\tif (child) child.kill(\"SIGTERM\");\n\tprocess.exit(0);\n});\n","sourceCodeStart":235,"sourceCodeEnd":262,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/serveronly/watcher.js#L235-L262","documentation":"The whole watch-target loading block is wrapped in try/catch; if reading or parsing config fails (file missing, invalid JS, throwing getter), the catch logs this warning and the watcher ends up with no configured targets from config. Watch mode then has no targets to monitor, similar to error 80.","triggerScenarios":"The config file cannot be loaded at runtime: config.js missing, contains a JavaScript syntax error or throws during evaluation, or the config-loading require/import throws for any reason.","commonSituations":"Broken config.js after a manual edit (unbalanced braces, stray comma); environment where the config path resolution differs (containers, systemd units with wrong WorkingDirectory); partially migrated configs referencing removed modules that throw on load.","solutions":["Validate config.js syntax (node --check config/config.js) and fix any errors","Ensure the config file exists at the expected path relative to rootDir","Check server logs from config loading for the underlying exception","Restore a known-good config and re-apply changes incrementally"],"exampleFix":"// before (config.js with syntax error)\nvar config = { address: \"0.0.0.0\";; };\n// after\nvar config = { address: \"0.0.0.0\" };","handlingStrategy":"fallback","validationCode":"let watchTargets = [];\ntry {\n  const cfg = require(configPath);\n  watchTargets = Array.isArray(cfg.watchTargets) ? cfg.watchTargets : [];\n} catch (err) {\n  console.error(\"Failed to load config:\", err.message);\n}","typeGuard":"function configLoads(configPath) {\n  try { require(configPath); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  const cfg = require(configPath);\n  useTargets(cfg.watchTargets);\n} catch (err) {\n  Log.warn(\"Could not load watchTargets from config.\");\n  useFallbackTargets();\n}","preventionTips":["Run node --check on config.js after every edit","Keep a backup of the last working config","Log the underlying exception, not just a generic message, to ease debugging"],"tags":["watch-mode","configuration","config-load"],"backgroundTag":"config-load-failure","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}