MagicMirrorOrg/MagicMirror · warning
Watch target is not a file (directories not supported): ${ta
Error message
Watch target is not a file (directories not supported): ${targetPath} What it means
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.
Source
Thrown at serveronly/watcher.js:248
// 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;
if (restartTimer) clearTimeout(restartTimer);
if (child) child.kill("SIGTERM");
process.exit(0);
});
View on GitHub (pinned to 4b4a59534f)
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
Example fix
// before watchTargets: ["modules/default/"] // after watchTargets: ["modules/default/default.js", "modules/default/node_helper.js"]
Defensive patterns
Strategy: validation
Validate before calling
const stats = fs.statSync(targetPath);
if (!stats.isFile()) {
console.warn(`Watch target must be a regular file: ${targetPath}`);
} Type guard
function isRegularFile(p) {
try { return fs.statSync(p).isFile(); } catch { return false; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Watch target does not exist: ${targetPath}
- 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/9e416341a274bc6b.
Report an issue: GitHub.