saadeghi/daisyui · error · Error
${flag} requires a value
Error message
${flag} requires a value What it means
Thrown by takeValue in pr-preview.mjs when a flag that expects a value (--base-sha, --head-sha, --output, --browser, or --timeout) is the last token on the command line, so argv[index + 1] is undefined.
Source
Thrown at packages/tailwind-play-share/pr-preview.mjs:33
const usage = `Usage:
bun packages/tailwind-play-share/pr-preview.mjs \\
--base-sha <sha> \\
--head-sha <sha> \\
--output <path>
Options:
--base-sha <sha> Pull request base commit
--head-sha <sha> Pull request head commit
--output <path> Write the generated preview metadata as JSON
--browser <path> Chrome/Chromium executable
--timeout <ms> Timeout for each browser operation (default: ${defaultTimeoutMs})
--verbose Write Tailwind Play progress information to stderr
--help Show this help`
function takeValue(argv, index, flag) {
const value = argv[index + 1]
if (value === undefined) throw new Error(`${flag} requires a value`)
return value
}
export function parsePreviewArgs(argv) {
const options = {
baseSha: undefined,
browser: undefined,
headSha: undefined,
help: false,
output: undefined,
timeoutMs: defaultTimeoutMs,
verbose: false,
}
for (let index = 0; index < argv.length; index += 1) {
const argument = argv[index]
switch (argument) {
case "--base-sha":View on GitHub (pinned to 42b09e637e)
Solutions
- Provide the value immediately after the flag: `--base-sha <sha>`.
- Quote the argument so the shell does not drop empty values.
- Run with --help to see the expected option shape.
Example fix
// before bun packages/tailwind-play-share/pr-preview.mjs --base-sha --head-sha abc --output out.json // after bun packages/tailwind-play-share/pr-preview.mjs --base-sha def --head-sha abc --output out.json
Defensive patterns
Strategy: validation
Validate before calling
function flagHasValue(argv, flagIndex) {
return argv[flagIndex + 1] !== undefined && !argv[flagIndex + 1].startsWith("--")
} Try / catch
try {
options = parsePreviewArgs(argv)
} catch (error) {
if (/requires a value$/.test(error.message)) {
// show usage and exit with a clear error
}
throw error
} Prevention
- Always pass a value immediately after each value-taking flag.
- Quote interpolated values in CI to avoid dropping empty SHAs.
- Validate argv shape before invoking parsePreviewArgs.
When it happens
Trigger: Invoking pr-preview.mjs with e.g. `--base-sha` and nothing after it, or the value being consumed as a different flag.
Common situations: A copy/paste CLI invocation missing the SHA, a shell that swallowed the value due to unquoted expansion, or a CI step that interpolates an empty variable (`--base-sha ${{ github.event.pull_request.base.sha }}` when empty).
Related errors
- Unknown option: ${argument}
- --timeout must be a positive number of milliseconds
- A daisyUI source file is required
- Unsupported daisyUI source file: ${sourceFile}
- ${flag} requires a value
AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13).
Data as JSON: /api/errors/513b0636c680af0e.
Report an issue: GitHub.