heygen-com/hyperframes · error · Error
[build-zip] could not resolve ${moduleName} from ${packageRo
Error message
[build-zip] could not resolve ${moduleName} from ${packageRoot} — run 'bun install' first. What it means
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.
Source
Thrown at packages/aws-lambda/scripts/build-zip.ts:326
const manifest = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf-8")) as {
dependencies?: Record<string, string>;
};
return manifest.dependencies?.[moduleName] ?? "latest";
}
return match[1];
}
function resolveModuleDir(moduleName: string): string {
// Walk up from packageRoot to find a matching node_modules entry.
// Used by stageFfmpeg below; the @sparticuz/chromium + puppeteer-core
// paths now go through npm install instead.
let dir = packageRoot;
for (let i = 0; i < 5; i++) {
const candidate = join(dir, "node_modules", moduleName);
if (existsSync(candidate)) return candidate;
dir = dirname(dir);
}
throw new Error(
`[build-zip] could not resolve ${moduleName} from ${packageRoot} — run 'bun install' first.`,
);
}
function stageHyperframeRuntime(stagingDir: string): void {
const coreDist = resolve(monorepoRoot, "packages/core/dist");
const manifestSrc = join(coreDist, "hyperframe.manifest.json");
const iifeSrc = join(coreDist, "hyperframe.runtime.iife.js");
if (!existsSync(manifestSrc) || !existsSync(iifeSrc)) {
throw new Error(
`[build-zip] hyperframe runtime artifacts missing under ${coreDist}. ` +
`Run 'bun run --filter @hyperframes/core build:hyperframes-runtime:modular' first.`,
);
}
cpSync(manifestSrc, join(stagingDir, "hyperframe.manifest.json"));
cpSync(iifeSrc, join(stagingDir, "hyperframe.runtime.iife.js"));
console.log(`[build-zip] staged hyperframe.manifest.json + hyperframe.runtime.iife.js`);
}View on GitHub (pinned to c2996c8626)
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.
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from "node:fs";
import { join, dirname } from "node:path";
function moduleInstalled(moduleName: string, startDir: string): boolean {
let dir = startDir;
for (let i = 0; i < 5; i++) {
if (existsSync(join(dir, "node_modules", moduleName))) return true;
dir = dirname(dir);
}
return false;
}
if (!moduleInstalled("ffmpeg-static", packageRoot)) {
console.error("ffmpeg-static not found. Run 'bun install' at the monorepo root.");
process.exit(1);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Fresh checkout without running bun install; the module was removed from dependencies; workspace hoisting placed the module beyond the 5-level walk-up limit.
Related errors
- [build-zip] npm install into staging failed (status ${result
- [build-zip] ffmpeg-static binary missing at ${ffmpegBinary}.
- whisper-cpp build failed. Ensure cmake and a C compiler are
- --source must be 'sparticuz' or 'chrome-headless-shell' (got
- Unknown flag: ${arg}
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/c7f607868fb5bd6d.
Report an issue: GitHub.