{"record":{"id":"9e416341a274bc6b","repo":"MagicMirrorOrg/MagicMirror","slug":"watch-target-is-not-a-file-directories-not-suppor","errorCode":null,"errorMessage":"Watch target is not a file (directories not supported): ${targetPath}","messagePattern":"Watch target is not a file \\(directories not supported\\): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"serveronly/watcher.js","lineNumber":248,"sourceCode":"\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);\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":230,"sourceCodeEnd":262,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/serveronly/watcher.js#L230-L262","documentation":"Watch targets must be regular files; directories are not supported by the watcher. After confirming the target exists, the watcher calls fs.statSync and only calls watchFile() when stats.isFile() is true; otherwise it logs this warning and skips the entry. Other targets continue to be watched.","triggerScenarios":"A watchTargets entry resolves to a directory (e.g. \"js\" or \"/var/log/mirror\") instead of a single file; the path exists but is a symlink to a directory, socket, or other non-regular file.","commonSituations":"Developers assuming recursive directory watching is supported; passing a folder that used to contain the watched file; wanting to watch all module files and listing the modules directory instead of individual files.","solutions":["Replace the directory entry with the specific file paths you want watched","List each file individually in watchTargets (e.g. \"modules/myModule/myModule.js\")","If you need directory watching, add a file watcher library like chokidar outside this watcher"],"exampleFix":"// before\nwatchTargets: [\"modules/default/\"]\n// after\nwatchTargets: [\"modules/default/default.js\", \"modules/default/node_helper.js\"]","handlingStrategy":"validation","validationCode":"const stats = fs.statSync(targetPath);\nif (!stats.isFile()) {\n  console.warn(`Watch target must be a regular file: ${targetPath}`);\n}","typeGuard":"function isRegularFile(p) {\n  try { return fs.statSync(p).isFile(); } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["List individual files, not directories, in watchTargets","Remember the watcher does not support recursive directory watching","Use isFile() checks on candidate paths during config authoring"],"tags":["watch-mode","filesystem","directories"],"backgroundTag":"unsupported-path-type","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}