laurent22/joplin · error · Error

Missing required flag value: %s

Error message

Missing required flag value: %s

What it means

For flags that take a required value (flagSpec.arg.required === true, e.g. '-f <notebook>'), Yargs represents a bare flag (given without a value) as the boolean true. makeCommandArgs detects value === true and throws 'Missing required flag value'. The message is i18n-translated.

Source

Thrown at packages/app-cli/app/cli-utils.ts:169

		output[a.name] = args['_'][i];
	}

	const argOptions: CommandArgs = {};
	for (const key in args) {
		if (!args.hasOwnProperty(key)) continue;
		if (key === '_') continue;
		argOptions[key] = args[key];
	}

	for (const [key, value] of Object.entries(argOptions)) {
		const flagSpec = flagSpecs.find(s => {
			return s.short === key || s.long === key;
		});
		if (flagSpec?.arg?.required) {
			// If a flag is required, and no value is provided for it, Yargs
			// sets the value to `true`.
			if (value === true) {
				throw new Error(_('Missing required flag value: %s', `-${flagSpec.short} <${flagSpec.arg.name}>`));
			}
		}
	}

	output.options = argOptions;

	return output;
};

cliUtils.promptMcq = function(message: string, answers: Record<string, string>): Promise<string> {
	const rl = readline.createInterface({
		input: process.stdin,
		output: process.stdout,
	});

	message += '\n\n';
	for (const n in answers) {
		if (!answers.hasOwnProperty(n)) continue;

View on GitHub (pinned to 2654b33620)

Solutions

  1. Provide the value immediately after the flag: '-f <notebook>'.
  2. Run '<command> --help' to confirm which flags require values (shown as -x <name>).
  3. Quote the value if it contains spaces.

Example fix

# before
#   joplin mknote -f "My note"
# after
#   joplin mknote -f "My notebook" "My note"
Defensive patterns

Strategy: validation

Validate before calling

for (const [key, value] of Object.entries(argOptions)) {
  const spec = flagSpecs.find(s => s.short === key || s.long === key);
  if (spec?.arg?.required && value === true) {
    throw new Error(`Provide a value for -${spec.short}`);
  }
}

Try / catch

try {
  await command.action(cliUtils.makeCommandArgs(command, argv));
} catch (e) {
  if (/Missing required flag value/.test(e.message)) command.stdout(command.usage());
}

Prevention

When it happens

Trigger: Supplying a value-taking flag without its argument — e.g. 'mknote -f' with no notebook name, or 'mkbook -h' style usage where the flag expects a value.

Common situations: Forgetting the argument after a flag; a flag that the user assumed was boolean but actually requires a value; shell parsing that detaches the value.

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/579577b691e71e4c. Report an issue: GitHub.