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

  1. Replace the directory entry with the specific file paths you want watched
  2. List each file individually in watchTargets (e.g. "modules/myModule/myModule.js")
  3. 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

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


AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31). Data as JSON: /api/errors/9e416341a274bc6b. Report an issue: GitHub.