saadeghi/daisyui · error · Error

${flag} requires a value

Error message

${flag} requires a value

What it means

takeValue reads argv[index+1] for value-taking flags (--html, --css, --html-file, --css-file, --browser, --timeout). It throws when that next token is undefined, i.e. the flag was the last token on the command line with no value after it.

Source

Thrown at packages/tailwind-play-share/index.mjs:36

Options:
  --html <code>       HTML source
  --css <code>        CSS source
  --html-file <path>  Read HTML from a file
  --css-file <path>   Read CSS from a file
  --browser <path>    Chrome/Chromium executable
  --timeout <ms>      Timeout for each browser operation (default: ${DEFAULT_TIMEOUT_MS})
  --headed            Show the browser window
  --verbose           Write progress information to stderr
  --help              Show this help

The created Tailwind Play URL is the only value written to stdout.
Set TAILWIND_PLAY_BROWSER or CHROME_PATH to configure the browser without a flag.`

function takeValue(argv, index, flag) {
  const value = argv[index + 1]
  if (value === undefined) {
    throw new Error(`${flag} requires a value`)
  }
  return value
}

function parseArgs(argv) {
  const options = {
    browser: undefined,
    css: undefined,
    cssFile: undefined,
    headed: false,
    help: false,
    html: undefined,
    htmlFile: undefined,
    timeoutMs: DEFAULT_TIMEOUT_MS,
    verbose: false,
  }
  const positional = []

View on GitHub (pinned to 42b09e637e)

Solutions

  1. Provide the value immediately after the flag.
  2. Quote the value so the shell does not drop it.
  3. Confirm the flag is not the last token.

Example fix

# before
bun .../index.mjs --html
# after
bun .../index.mjs --html '<div>hi</div>'
Defensive patterns

Strategy: validation

Validate before calling

// Before calling, ensure every value flag has a following non-flag token.
function ensureValuesProvided(argv, valueFlags) {
  for (let i = 0; i < argv.length; i += 1) {
    if (valueFlags.includes(argv[i]) && argv[i + 1] === undefined) {
      throw new Error(`${argv[i]} requires a value`)
    }
  }
}

Prevention

When it happens

Trigger: A value flag placed at the end of the command line; a flag whose value was consumed/dropped by shell quoting; a flag followed by another flag instead of a value.

Common situations: Shell removed an empty quoted value; copy-paste left `--html` with nothing after it; user assumed the flag was boolean.

Related errors


AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13). Data as JSON: /api/errors/2559c37515144feb. Report an issue: GitHub.