MagicMirrorOrg/MagicMirror · warning
Watch mode is enabled but no watchTargets are configured. No
Error message
Watch mode is enabled but no watchTargets are configured. No files will be monitored. Set the watchTargets array in your config.js to enable file watching.
What it means
The MagicMirror serveronly watcher enables watch mode but found no usable watchTargets: either config.watchTargets is not an array, is empty, or contains only non-string/empty entries. The library logs this warning because watch mode without targets cannot monitor any files, so automatic restarts on file changes are disabled. It is non-fatal: the server continues running without watching.
Source
Thrown at serveronly/watcher.js:226
Log.error(`Failed to watch file ${file}:`, error.message);
}
}
startServer();
// Setup file watching based on config
try {
const configPath = getConfigFilePath();
delete require.cache[require.resolve(configPath)];
const config = require(configPath);
let watchTargets = [];
if (Array.isArray(config.watchTargets) && config.watchTargets.length > 0) {
watchTargets = config.watchTargets.filter((target) => typeof target === "string" && target.trim() !== "");
}
if (watchTargets.length === 0) {
Log.warn("Watch mode is enabled but no watchTargets are configured. No files will be monitored. Set the watchTargets array in your config.js to enable file watching.");
}
Log.log(`Watch mode enabled. Watching ${watchTargets.length} file(s)`);
// Watch each target file
for (const target of watchTargets) {
const targetPath = path.isAbsolute(target)
? target
: 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);View on GitHub (pinned to 4b4a59534f)
Solutions
- Add a non-empty watchTargets array of file paths to your config.js
- Verify each entry is a non-empty string (paths are joined against rootDir if relative)
- Confirm watch mode is actually intended; if not, disable watch mode to remove the warning
- Check spelling of the config key watchTargets
Example fix
// before
var config = { watch: true };
// after
var config = { watch: true, watchTargets: ["js/server.js", "config/config.js"] }; Defensive patterns
Strategy: validation
Validate before calling
const targets = Array.isArray(config.watchTargets)
? config.watchTargets.filter((t) => typeof t === "string" && t.trim() !== "")
: [];
if (targets.length === 0 && watchModeEnabled) {
console.warn("Watch mode enabled but no valid watchTargets configured");
} Type guard
function hasWatchTargets(config) {
return Array.isArray(config.watchTargets) &&
config.watchTargets.some((t) => typeof t === "string" && t.trim() !== "");
} Prevention
- Always pair enabling watch mode with a populated watchTargets array
- Filter entries to non-empty strings before starting the watcher
- Add a startup assertion that watchTargets is a non-empty array when watch mode is on
When it happens
Trigger: config.js does not define watchTargets; watchTargets is set to []; watchTargets contains only values failing the filter (non-strings or whitespace-only strings) while watch mode is enabled.
Common situations: Developers enable watch mode (e.g. serveronly with watch flag or watch: true) but forget to add the watchTargets array; copying a config template without the watchTargets section; typos like watchtarget or watch-Targets; all entries being blank after manual editing.
Related errors
- Could not load watchTargets from config.
- 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/5fa4f056eadd94a9.
Report an issue: GitHub.