MagicMirrorOrg/MagicMirror · warning
Could not load watchTargets from config.
Error message
Could not load watchTargets from config.
What it means
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.
Source
Thrown at serveronly/watcher.js:253
: path.join(rootDir, target);
// Check if file exists
if (!fs.existsSync(targetPath)) {
Log.warn(`Watch target does not exist: ${targetPath}`);
continue;
}
// Check if it's a file (directories are not supported)
const stats = fs.statSync(targetPath);
if (stats.isFile()) {
watchFile(targetPath);
} else {
Log.warn(`Watch target is not a file (directories not supported): ${targetPath}`);
}
}
} catch {
// Config file might not exist or be invalid, use fallback targets
Log.warn("Could not load watchTargets from config.");
}
process.on("SIGINT", () => {
isShuttingDown = true;
if (restartTimer) clearTimeout(restartTimer);
if (child) child.kill("SIGTERM");
process.exit(0);
});
View on GitHub (pinned to 4b4a59534f)
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
Example fix
// before (config.js with syntax error)
var config = { address: "0.0.0.0";; };
// after
var config = { address: "0.0.0.0" }; Defensive patterns
Strategy: fallback
Validate before calling
let watchTargets = [];
try {
const cfg = require(configPath);
watchTargets = Array.isArray(cfg.watchTargets) ? cfg.watchTargets : [];
} catch (err) {
console.error("Failed to load config:", err.message);
} Type guard
function configLoads(configPath) {
try { require(configPath); return true; } catch { return false; }
} Try / catch
try {
const cfg = require(configPath);
useTargets(cfg.watchTargets);
} catch (err) {
Log.warn("Could not load watchTargets from config.");
useFallbackTargets();
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Watch mode is enabled but no watchTargets are configured. No
- This device is not allowed to access your mirror. <br> Pleas
- <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8
- CORS proxy is disabled
- Forbidden: domain not in corsDomainWhitelist
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/18fda78376ef32b0.
Report an issue: GitHub.