{"record":{"id":"f621204ca8add9d8","repo":"heygen-com/hyperframes","slug":"missing-browser-script-name","errorCode":null,"errorMessage":"Missing browser script ${name}","messagePattern":"Missing browser script (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/layout.ts","lineNumber":293,"sourceCode":"      duration,\n      samples,\n      transitionSamples,\n      transitionSamplesDropped,\n      rawIssues: dedupeLayoutIssues(issues),\n      motionSamples,\n    };\n  } finally {\n    await chromeBrowser?.close().catch(() => {});\n    await server.close();\n  }\n}\n\nexport function loadBrowserScript(name: string): string {\n  const candidates = [join(__dirname, name), join(__dirname, \"commands\", name)];\n  for (const candidate of candidates) {\n    if (existsSync(candidate)) return readFileSync(candidate, \"utf-8\");\n  }\n  throw new Error(`Missing browser script ${name}`);\n}\n\nfunction loadLayoutAuditScript(): string {\n  return loadBrowserScript(\"layout-audit.browser.js\");\n}\n\nasync function collectLayoutIssues(\n  page: import(\"puppeteer-core\").Page,\n  samples: number[],\n  tolerance: number,\n): Promise<LayoutIssue[]> {\n  if (samples.length === 0) return [];\n  await page.addScriptTag({ content: loadLayoutAuditScript() });\n\n  const issues: LayoutIssue[] = [];\n  for (const time of samples) {\n    await seekCompositionTimeline(page, time, LAYOUT_SEEK_OPTIONS);\n    const sampleIssues = await page.evaluate(","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/layout.ts#L275-L311","documentation":"Thrown by loadBrowserScript() in packages/cli/src/commands/layout.ts:288. It looks for the named asset (e.g. layout-audit.browser.js) in two locations under __dirname — the current dir and a `commands/` subdir — and throws if neither exists. These .browser.js files are build artifacts that must be copied into the package output; they are not in the source tree at runtime.","triggerScenarios":"Calling loadBrowserScript (directly or via loadLayoutAuditScript -> collectLayoutIssues during `hyperframes lint`/layout checks) when the .browser.js asset wasn't emitted into the dist dir, or when called with a name that doesn't correspond to a shipped script.","commonSituations":"Incomplete build (`bun run build` didn't copy the .browser.js asset); monorepo/workspace linking where __dirname resolves to src rather than dist; typo or wrong name passed to loadBrowserScript; stale dist from before the asset was added.","solutions":["Rebuild the CLI package (`bun run build`) and confirm the .browser.js file appears next to the compiled layout.js.","If using workspace linking, run from the built dist directory rather than src, or rebuild after edits.","Check the script name passed in matches an actual shipped asset (layout-audit.browser.js is the canonical one).","Report a packaging bug if the asset is present in source build config but missing from the published tarball."],"exampleFix":"# before: running from a stale/incomplete dist\nhyperframes lint\n# after: rebuild so the browser asset is copied next to layout.js\nbun run build\nhyperframes lint","handlingStrategy":"validation","validationCode":"import { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nfunction loadScriptOrThrow(name: string, dir: string): string {\n  const candidates = [join(dir, name), join(dir, 'commands', name)];\n  const found = candidates.find(existsSync);\n  if (!found) throw new Error(`Missing browser script ${name}; rebuild the CLI package.`);\n  return readFileSync(found, 'utf-8');\n}","typeGuard":null,"tryCatchPattern":"try {\n  loadBrowserScript('layout-audit.browser.js');\n} catch (error) {\n  if (/Missing browser script/.test(String(error))) {\n    // rebuild and retry once\n    childProcess.execSync('bun run build', { stdio: 'inherit' });\n    loadBrowserScript('layout-audit.browser.js');\n  } else throw error;\n}","preventionTips":["Run `bun run build` after pulling changes and before invoking lint/layout checks.","When workspace-linking the CLI, run from the built dist dir, not src.","Add a postbuild assertion that .browser.js assets exist next to the compiled output."],"tags":["build","filesystem","internal","layout"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}