saadeghi/daisyui · critical · Error
This dependency-free script requires Node.js 22 or newer (gl
Error message
This dependency-free script requires Node.js 22 or newer (global WebSocket support)
What it means
Thrown at the top of createTailwindPlay when typeof WebSocket !== "function". The script drives Chrome via a raw WebSocket (CdpClient) and intentionally has zero dependencies, so it relies on a global WebSocket, which Node.js only exposes globally from v22.
Source
Thrown at packages/tailwind-play-share/index.mjs:925
await delay(150)
}
const alertText = lastState?.alerts?.length
? ` Tailwind Play reported: ${lastState.alerts.join(" ")}`
: ""
throw new Error(`Timed out waiting for Tailwind Play to create a share URL.${alertText}`)
}
export async function createTailwindPlay({
browser,
css = "",
headed = false,
html = "",
timeoutMs = DEFAULT_TIMEOUT_MS,
verbose = false,
}) {
if (typeof WebSocket !== "function") {
throw new Error(
"This dependency-free script requires Node.js 22 or newer (global WebSocket support)",
)
}
const log = (...values) => {
if (verbose) console.error(...values)
}
const executable = await findBrowser(browser)
const profileDirectory = await mkdtemp(join(tmpdir(), "tailwind-play-share-"))
let browserProcess
let client
try {
log(`Starting ${executable}`)
const launched = await launchBrowser(executable, { headed, profileDirectory, timeoutMs })
browserProcess = launched.browserProcess
client = new CdpClient(await getPageWebSocketUrl(launched.port))View on GitHub (pinned to 42b09e637e)
Solutions
- Run under Node.js >= 22 (check with `node --version`).
- Run with `bun packages/tailwind-play-share/index.mjs ...` since Bun ships a global WebSocket.
- Upgrade the Node version in your CI image.
Example fix
// before node packages/tailwind-play-share/index.mjs --html '<div/>' --css '' // after bun packages/tailwind-play-share/index.mjs --html '<div/>' --css '' // or upgrade: nvm use 22 && node packages/tailwind-play-share/index.mjs ...
Defensive patterns
Strategy: validation
Validate before calling
function assertRuntimeHasWebSocket() {
if (typeof WebSocket !== "function") {
throw new Error("Run with Node.js >= 22 or Bun; global WebSocket is required")
}
}
assertRuntimeHasWebSocket() Type guard
const hasGlobalWebSocket = typeof WebSocket === "function"
Try / catch
try {
url = await createTailwindPlay(inputs)
} catch (error) {
if (error.message.includes("Node.js 22 or newer")) {
// switch runtime to Bun or Node >= 22, then re-run
}
throw error
} Prevention
- Pin your runtime to Node >= 22 or Bun in CI and locally.
- Check `typeof WebSocket` before calling createTailwindPlay.
- Document the runtime requirement where the script is invoked.
When it happens
Trigger: Running the script under Node.js < 22 (or a runtime without a global WebSocket) so the typeof check fails immediately, before any browser work.
Common situations: CI image pinned to Node 18/20, an older local node in PATH, or running with `node` instead of `bun` on a machine where node is outdated.
Related errors
- Browser executable not found or not executable: ${configured
- Chrome or Chromium was not found. Set TAILWIND_PLAY_BROWSER
AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13).
Data as JSON: /api/errors/38bea054a1cb7010.
Report an issue: GitHub.