saadeghi/daisyui · error · Error

A daisyUI source file is required

Error message

A daisyUI source file is required

What it means

build-daisyui.js expects exactly one CLI argument: the path to a daisyUI source CSS file. It reads process.argv[2] and throws immediately when that value is falsy. The script then maps the file to one of four source groups, so without an argument it cannot proceed.

Source

Thrown at packages/playground/build-daisyui.js:29

  [resolve(daisyuiRoot, "src/base"), { type: "base", outputRoot: resolve(daisyuiRoot, "base") }],
  [
    resolve(daisyuiRoot, "src/components"),
    { type: "component", outputRoot: resolve(daisyuiRoot, "components") },
  ],
  [
    resolve(daisyuiRoot, "src/themes"),
    { type: "base", outputRoot: resolve(daisyuiRoot, "theme"), themes: true },
  ],
  [
    resolve(daisyuiRoot, "src/utilities"),
    { type: "utility", outputRoot: resolve(daisyuiRoot, "utilities") },
  ],
])

const inputFile = process.argv[2]

if (!inputFile) {
  throw new Error("A daisyUI source file is required")
}

const sourceFile = resolve(inputFile)
const sourceGroup = sourceGroups.get(dirname(sourceFile))

if (!sourceGroup || !sourceFile.endsWith(".css")) {
  throw new Error(`Unsupported daisyUI source file: ${sourceFile}`)
}

const name = basename(sourceFile, ".css")
const [styles, outputDirectory] = await Promise.all([
  cssToJs(sourceFile),
  createDirectoryBasedOnFileNames(name, ".css", sourceGroup.outputRoot),
])

await createPluginFiles(sourceGroup.type, outputDirectory, styles, name)

if (sourceGroup.themes) {

View on GitHub (pinned to 42b09e637e)

Solutions

  1. Pass the source CSS file path as the first argument.
  2. If calling from a script, ensure the file path is forwarded as process.argv[2].
  3. Run with no args only if you meant a different entry point.

Example fix

// before
bun packages/playground/build-daisyui.js
// after
bun packages/playground/build-daisyui.js packages/daisyui/src/components/button.css
Defensive patterns

Strategy: validation

Validate before calling

const inputFile = process.argv[2]
if (!inputFile) {
  console.error('Usage: build-daisyui.js <packages/daisyui/src/.../file.css>')
  process.exit(2)
}

Type guard

const isNonEmptyString = (v) => typeof v === 'string' && v.length > 0

Prevention

When it happens

Trigger: Running `bun packages/playground/build-daisyui.js` (or `node ...`) with no positional argument, or with argv stripped by a wrapper.

Common situations: A new contributor runs the build script directly without reading its usage; a npm/script entry forgets to forward the file path; CI invokes the script in a step that passes no argument.

Related errors


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