MagicMirrorOrg/MagicMirror · warning

Watch mode is enabled but no watchTargets are configured. No

Error message

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.

What it means

The MagicMirror serveronly watcher enables watch mode but found no usable watchTargets: either config.watchTargets is not an array, is empty, or contains only non-string/empty entries. The library logs this warning because watch mode without targets cannot monitor any files, so automatic restarts on file changes are disabled. It is non-fatal: the server continues running without watching.

Source

Thrown at serveronly/watcher.js:226

		Log.error(`Failed to watch file ${file}:`, error.message);
	}
}

startServer();

// Setup file watching based on config
try {
	const configPath = getConfigFilePath();
	delete require.cache[require.resolve(configPath)];
	const config = require(configPath);

	let watchTargets = [];
	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);

View on GitHub (pinned to 4b4a59534f)

Solutions

  1. Add a non-empty watchTargets array of file paths to your config.js
  2. Verify each entry is a non-empty string (paths are joined against rootDir if relative)
  3. Confirm watch mode is actually intended; if not, disable watch mode to remove the warning
  4. Check spelling of the config key watchTargets

Example fix

// before
var config = { watch: true };
// after
var config = { watch: true, watchTargets: ["js/server.js", "config/config.js"] };
Defensive patterns

Strategy: validation

Validate before calling

const targets = Array.isArray(config.watchTargets)
  ? config.watchTargets.filter((t) => typeof t === "string" && t.trim() !== "")
  : [];
if (targets.length === 0 && watchModeEnabled) {
  console.warn("Watch mode enabled but no valid watchTargets configured");
}

Type guard

function hasWatchTargets(config) {
  return Array.isArray(config.watchTargets) &&
    config.watchTargets.some((t) => typeof t === "string" && t.trim() !== "");
}

Prevention

When it happens

Trigger: config.js does not define watchTargets; watchTargets is set to []; watchTargets contains only values failing the filter (non-strings or whitespace-only strings) while watch mode is enabled.

Common situations: Developers enable watch mode (e.g. serveronly with watch flag or watch: true) but forget to add the watchTargets array; copying a config template without the watchTargets section; typos like watchtarget or watch-Targets; all entries being blank after manual editing.

Related errors


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