MagicMirrorOrg/MagicMirror · warning
Watch target does not exist: ${targetPath}
Error message
Watch target does not exist: ${targetPath} What it means
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.
Source
Thrown at serveronly/watcher.js:239
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);
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;View on GitHub (pinned to 4b4a59534f)
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
Example fix
// before watchTargets: ["js/serve.js"] // after (typo fixed) watchTargets: ["js/server.js"]
Defensive patterns
Strategy: validation
Validate before calling
const fs = require("fs");
const targetPath = path.isAbsolute(target) ? target : path.join(rootDir, target);
if (!fs.existsSync(targetPath)) {
console.warn(`Skipping missing watch target: ${targetPath}`);
} Type guard
function watchTargetExists(target, rootDir) {
const p = path.isAbsolute(target) ? target : path.join(rootDir, target);
return fs.existsSync(p);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Watch target is not a file (directories not supported): ${ta
- No ${moduleFile} found for module: ${moduleName}.
- WARNING! Your custom css file was moved from ${global.root_p
- WARNING! Your custom css file is currently located in the cs
- Watch mode is enabled but no watchTargets are configured. No
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/84f880b847a9aa51.
Report an issue: GitHub.