{"record":{"id":"5fa4f056eadd94a9","repo":"MagicMirrorOrg/MagicMirror","slug":"watch-mode-is-enabled-but-no-watchtargets-are-conf","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"serveronly/watcher.js","lineNumber":226,"sourceCode":"\t\tLog.error(`Failed to watch file ${file}:`, error.message);\n\t}\n}\n\nstartServer();\n\n// Setup file watching based on config\ntry {\n\tconst configPath = getConfigFilePath();\n\tdelete require.cache[require.resolve(configPath)];\n\tconst config = require(configPath);\n\n\tlet watchTargets = [];\n\tif (Array.isArray(config.watchTargets) && config.watchTargets.length > 0) {\n\t\twatchTargets = config.watchTargets.filter((target) => typeof target === \"string\" && target.trim() !== \"\");\n\t}\n\n\tif (watchTargets.length === 0) {\n\t\tLog.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.\");\n\t}\n\n\tLog.log(`Watch mode enabled. Watching ${watchTargets.length} file(s)`);\n\n\t// Watch each target file\n\tfor (const target of watchTargets) {\n\t\tconst targetPath = path.isAbsolute(target)\n\t\t\t? target\n\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);","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/serveronly/watcher.js#L208-L244","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar config = { watch: true };\n// after\nvar config = { watch: true, watchTargets: [\"js/server.js\", \"config/config.js\"] };","handlingStrategy":"validation","validationCode":"const targets = Array.isArray(config.watchTargets)\n  ? config.watchTargets.filter((t) => typeof t === \"string\" && t.trim() !== \"\")\n  : [];\nif (targets.length === 0 && watchModeEnabled) {\n  console.warn(\"Watch mode enabled but no valid watchTargets configured\");\n}","typeGuard":"function hasWatchTargets(config) {\n  return Array.isArray(config.watchTargets) &&\n    config.watchTargets.some((t) => typeof t === \"string\" && t.trim() !== \"\");\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["watch-mode","configuration","warning"],"backgroundTag":"missing-config-option","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}