{"record":{"id":"38bea054a1cb7010","repo":"saadeghi/daisyui","slug":"this-dependency-free-script-requires-node-js-22-or","errorCode":null,"errorMessage":"This dependency-free script requires Node.js 22 or newer (global WebSocket support)","messagePattern":"This dependency-free script requires Node\\.js 22 or newer \\(global WebSocket support\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/tailwind-play-share/index.mjs","lineNumber":925,"sourceCode":"    await delay(150)\n  }\n\n  const alertText = lastState?.alerts?.length\n    ? ` Tailwind Play reported: ${lastState.alerts.join(\" \")}`\n    : \"\"\n  throw new Error(`Timed out waiting for Tailwind Play to create a share URL.${alertText}`)\n}\n\nexport async function createTailwindPlay({\n  browser,\n  css = \"\",\n  headed = false,\n  html = \"\",\n  timeoutMs = DEFAULT_TIMEOUT_MS,\n  verbose = false,\n}) {\n  if (typeof WebSocket !== \"function\") {\n    throw new Error(\n      \"This dependency-free script requires Node.js 22 or newer (global WebSocket support)\",\n    )\n  }\n\n  const log = (...values) => {\n    if (verbose) console.error(...values)\n  }\n  const executable = await findBrowser(browser)\n  const profileDirectory = await mkdtemp(join(tmpdir(), \"tailwind-play-share-\"))\n  let browserProcess\n  let client\n\n  try {\n    log(`Starting ${executable}`)\n    const launched = await launchBrowser(executable, { headed, profileDirectory, timeoutMs })\n    browserProcess = launched.browserProcess\n\n    client = new CdpClient(await getPageWebSocketUrl(launched.port))","sourceCodeStart":907,"sourceCodeEnd":943,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/index.mjs#L907-L943","documentation":"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.","triggerScenarios":"Running the script under Node.js < 22 (or a runtime without a global WebSocket) so the typeof check fails immediately, before any browser work.","commonSituations":"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.","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."],"exampleFix":"// before\nnode packages/tailwind-play-share/index.mjs --html '<div/>' --css ''\n\n// after\nbun packages/tailwind-play-share/index.mjs --html '<div/>' --css ''\n// or upgrade: nvm use 22 && node packages/tailwind-play-share/index.mjs ...","handlingStrategy":"validation","validationCode":"function assertRuntimeHasWebSocket() {\n  if (typeof WebSocket !== \"function\") {\n    throw new Error(\"Run with Node.js >= 22 or Bun; global WebSocket is required\")\n  }\n}\nassertRuntimeHasWebSocket()","typeGuard":"const hasGlobalWebSocket = typeof WebSocket === \"function\"","tryCatchPattern":"try {\n  url = await createTailwindPlay(inputs)\n} catch (error) {\n  if (error.message.includes(\"Node.js 22 or newer\")) {\n  // switch runtime to Bun or Node >= 22, then re-run\n  }\n  throw error\n}","preventionTips":["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."],"tags":["node-version","runtime","websocket","environment"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}