saadeghi/daisyui · error · Error
css must be a string
Error message
css must be a string
What it means
Mirror of the html type check: if css is defined but not a string (number, array, object, or null), the script throws. null for css is treated as a bad type, not as absent.
Source
Thrown at packages/tailwind-play-share/index.mjs:170
let parsed
try {
parsed = JSON.parse(stdin)
} catch (error) {
throw new Error(`stdin must be JSON with html and css strings: ${error.message}`)
}
html = parsed.html
css = parsed.css
}
}
if (html === undefined && css === undefined) {
throw new Error("Provide HTML/CSS using arguments, files, or JSON on stdin")
}
if (html !== undefined && typeof html !== "string") {
throw new Error("html must be a string")
}
if (css !== undefined && typeof css !== "string") {
throw new Error("css must be a string")
}
return { html: html ?? "", css: css ?? "" }
}
async function isExecutable(filePath) {
try {
await access(filePath, process.platform === "win32" ? fsConstants.F_OK : fsConstants.X_OK)
return true
} catch {
return false
}
}
async function resolveExecutable(candidate) {
if (!candidate) return undefined
if (isAbsolute(candidate) || candidate.includes("/") || candidate.includes("\\")) {View on GitHub (pinned to 42b09e637e)
Solutions
- Ensure the css field is a JSON string.
- Omit the css key if you have no CSS.
- Coerce css to a string before emitting JSON.
Example fix
# before
echo '{"html":"<div/>","css":null}' | bun .../index.mjs
# after
echo '{"html":"<div/>","css":""}' | bun .../index.mjs Defensive patterns
Strategy: type-guard
Validate before calling
if (css !== undefined && typeof css !== 'string') {
throw new Error('css must be a string')
} Type guard
const isOptionalString = (v) => v === undefined || typeof v === 'string'
Prevention
- Serialise css as a JSON string in your producer.
- Omit the css key rather than passing null when you have none.
- Validate the JSON shape with a schema before piping.
When it happens
Trigger: Piping JSON like `{"css":42}`, `{"css":{"import":true}}`, or `{"css":null}`.
Common situations: Producer serializes an object/number for css; null intended to mean 'no css'.
Related errors
- html must be a string
- stdin must be JSON with html and css strings: ${error.messag
- Provide HTML/CSS using arguments, files, or JSON on stdin
- --timeout must be a positive number of milliseconds
- --timeout must be a positive number of milliseconds
AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13).
Data as JSON: /api/errors/b1e8633f3935a306.
Report an issue: GitHub.