{"record":{"id":"84f880b847a9aa51","repo":"MagicMirrorOrg/MagicMirror","slug":"watch-target-does-not-exist-targetpath","errorCode":null,"errorMessage":"Watch target does not exist: ${targetPath}","messagePattern":"Watch target does not exist: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"serveronly/watcher.js","lineNumber":239,"sourceCode":"\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);\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;","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/serveronly/watcher.js#L221-L257","documentation":"The watcher resolves each watch target to an absolute path (relative targets are joined against rootDir) and checks existence with fs.existsSync. If the file does not exist, it logs this warning and skips the target with continue. Watching proceeds for remaining valid targets; this single target is simply ignored.","triggerScenarios":"A watchTargets entry points to a path that does not exist on disk: a typo in the filename, a relative path interpreted from the wrong rootDir, a deleted/renamed file, or an absolute path from another machine/container.","commonSituations":"Config copied between environments where absolute paths differ; missing build artifacts (target generated at runtime); case-sensitivity mismatches on Linux; symlinked project roots resolving differently.","solutions":["Correct the path in watchTargets so it points to an existing file","Use paths relative to the MagicMirror rootDir or fully valid absolute paths","Verify the file exists with ls/stat before starting watch mode","Remove stale entries for files that were deleted or renamed"],"exampleFix":"// before\nwatchTargets: [\"js/serve.js\"]\n// after (typo fixed)\nwatchTargets: [\"js/server.js\"]","handlingStrategy":"validation","validationCode":"const fs = require(\"fs\");\nconst targetPath = path.isAbsolute(target) ? target : path.join(rootDir, target);\nif (!fs.existsSync(targetPath)) {\n  console.warn(`Skipping missing watch target: ${targetPath}`);\n}","typeGuard":"function watchTargetExists(target, rootDir) {\n  const p = path.isAbsolute(target) ? target : path.join(rootDir, target);\n  return fs.existsSync(p);\n}","tryCatchPattern":null,"preventionTips":["Verify each watchTargets path exists with ls/stat before starting","Prefer paths relative to rootDir over machine-specific absolute paths","Remove entries for files that were deleted or renamed"],"tags":["watch-mode","filesystem","path-resolution"],"backgroundTag":"file-not-found","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}