{"record":{"id":"c7f607868fb5bd6d","repo":"heygen-com/hyperframes","slug":"build-zip-could-not-resolve-modulename-from","errorCode":null,"errorMessage":"[build-zip] could not resolve ${moduleName} from ${packageRoot} — run 'bun install' first.","messagePattern":"\\[build-zip\\] could not resolve (.+?) from (.+?) — run 'bun install' first\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/aws-lambda/scripts/build-zip.ts","lineNumber":326,"sourceCode":"    const manifest = JSON.parse(readFileSync(join(packageRoot, \"package.json\"), \"utf-8\")) as {\n      dependencies?: Record<string, string>;\n    };\n    return manifest.dependencies?.[moduleName] ?? \"latest\";\n  }\n  return match[1];\n}\n\nfunction resolveModuleDir(moduleName: string): string {\n  // Walk up from packageRoot to find a matching node_modules entry.\n  // Used by stageFfmpeg below; the @sparticuz/chromium + puppeteer-core\n  // paths now go through npm install instead.\n  let dir = packageRoot;\n  for (let i = 0; i < 5; i++) {\n    const candidate = join(dir, \"node_modules\", moduleName);\n    if (existsSync(candidate)) return candidate;\n    dir = dirname(dir);\n  }\n  throw new Error(\n    `[build-zip] could not resolve ${moduleName} from ${packageRoot} — run 'bun install' first.`,\n  );\n}\n\nfunction stageHyperframeRuntime(stagingDir: string): void {\n  const coreDist = resolve(monorepoRoot, \"packages/core/dist\");\n  const manifestSrc = join(coreDist, \"hyperframe.manifest.json\");\n  const iifeSrc = join(coreDist, \"hyperframe.runtime.iife.js\");\n  if (!existsSync(manifestSrc) || !existsSync(iifeSrc)) {\n    throw new Error(\n      `[build-zip] hyperframe runtime artifacts missing under ${coreDist}. ` +\n        `Run 'bun run --filter @hyperframes/core build:hyperframes-runtime:modular' first.`,\n    );\n  }\n  cpSync(manifestSrc, join(stagingDir, \"hyperframe.manifest.json\"));\n  cpSync(iifeSrc, join(stagingDir, \"hyperframe.runtime.iife.js\"));\n  console.log(`[build-zip] staged hyperframe.manifest.json + hyperframe.runtime.iife.js`);\n}","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/aws-lambda/scripts/build-zip.ts#L308-L344","documentation":"resolveModuleDir walks up to 5 parent directories from packageRoot looking for node_modules/<moduleName>. If it does not find a matching directory after 5 levels, it throws. This function is used by stageFfmpeg and stageChromeHeadlessShell to locate ffmpeg-static, ffprobe-static, and related packages.","triggerScenarios":"The named module (e.g., ffmpeg-static) is not present in any node_modules directory reachable by walking up from the aws-lambda package root. Most commonly because bun install has not been run in the monorepo.","commonSituations":"Fresh checkout without running bun install; the module was removed from dependencies; workspace hoisting placed the module beyond the 5-level walk-up limit.","solutions":["Run 'bun install' at the monorepo root.","Verify the module is listed in the aws-lambda package.json dependencies.","Check that the module appears in node_modules/ somewhere up the directory tree."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nfunction moduleInstalled(moduleName: string, startDir: string): boolean {\n  let dir = startDir;\n  for (let i = 0; i < 5; i++) {\n    if (existsSync(join(dir, \"node_modules\", moduleName))) return true;\n    dir = dirname(dir);\n  }\n  return false;\n}\nif (!moduleInstalled(\"ffmpeg-static\", packageRoot)) {\n  console.error(\"ffmpeg-static not found. Run 'bun install' at the monorepo root.\");\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run 'bun install' at the monorepo root before invoking build-zip.","Verify required modules are in the aws-lambda package.json dependencies.","Check for workspace hoisting issues if modules are deeper than 5 levels."],"tags":["npm","build","dependencies","module-resolution"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}