knex/knex · error · Error

Missing value for --mode

Error message

Missing value for --mode

What it means

parseMode in resolve-schema-snippets-docker.mjs (line 223) reads the --mode flag. If --mode is present but no value follows, line 227 throws 'Missing value for --mode'. Allowed values are 'live' or 'compile' (MODES set, line 17); default is 'live'.

Source

Thrown at docs/scripts/resolve-schema-snippets-docker.mjs:228

    if (names.includes(args[i])) {
      const value = args[i + 1];
      if (!value) {
        throw new Error(`Missing value for ${args[i]}`);
      }
      i += 1;
      values.push(...value.split(',').map((entry) => entry.trim()));
    }
  }
  const filtered = values.filter(Boolean);
  return filtered.length ? new Set(filtered) : null;
}

function parseMode(args) {
  for (let i = 0; i < args.length; i += 1) {
    if (args[i] === '--mode') {
      const value = args[i + 1];
      if (!value) {
        throw new Error('Missing value for --mode');
      }
      i += 1;
      if (!MODES.has(value)) {
        throw new Error(`Unknown mode: ${value}`);
      }
      return value;
    }
  }
  return DEFAULT_MODE;
}

function selectGroups(dialectFilter, dbFilter) {
  const byDefault = groups.filter((group) => group.default);
  const byDb = dbFilter
    ? groups.filter((group) => dbFilter.has(group.name))
    : null;

  if (dbFilter) {

View on GitHub (pinned to e25d54bcb7)

Solutions

  1. Provide a value: --mode live or --mode compile.
  2. Omit --mode entirely to use the default 'live'.
  3. Ensure the shell variable is non-empty before interpolating: --mode "${MODE:-live}".
  4. Run with --help for the option list.

Example fix

# before
node docs/scripts/resolve-schema-snippets-docker.mjs --mode
# after
node docs/scripts/resolve-schema-snippets-docker.mjs --mode compile
Defensive patterns

Strategy: validation

Validate before calling

const modeIdx = process.argv.indexOf('--mode');
if (modeIdx !== -1 && !process.argv[modeIdx + 1]) {
  console.error('--mode requires a value: live | compile');
  process.exit(2);
}

Type guard

const modeIsValid = (args) => {
  const i = args.indexOf('--mode');
  return i === -1 || (args[i+1] && ['live','compile'].includes(args[i+1]));
};

Prevention

When it happens

Trigger: Running 'node resolve-schema-snippets-docker.mjs --mode' with no following argument, or where the value was an empty/unset shell variable.

Common situations: Incomplete CLI invocation; empty $MODE env expansion passed as nothing; script wrapper that conditionally adds --mode but forgets the value.

Related errors


AI-assisted analysis of knex/knex@e25d54bcb7 (2026-08-03). Data as JSON: /data/errors/b0566279ac1933c2.json. Report an issue: GitHub.