remotion-dev/remotion · error · Error

Could not parse `window.remotion_publicPath` in the bundle i

Error message

Could not parse `window.remotion_publicPath` in the bundle index.html.

What it means

Thrown by getPublicPath() inside validateBundleDir() when the regex matched a `window.remotion_publicPath = "...";` assignment in index.html but the captured string could not be JSON.parsed. This means the bundle's index.html is syntactically malformed at that specific line.

Source

Thrown at packages/lambda/src/shared/validate-bundle-dir.ts:16

import fs from 'node:fs';
import path from 'node:path';

const getPublicPath = (indexHtml: string): unknown => {
	const match = indexHtml.match(
		/window\.remotion_publicPath\s*=\s*("(?:[^"\\]|\\.)*")\s*;/,
	);

	if (!match) {
		return null;
	}

	try {
		return JSON.parse(match[1]);
	} catch (error) {
		throw new Error(
			'Could not parse `window.remotion_publicPath` in the bundle index.html.',
			{cause: error},
		);
	}
};

const validateNoDirectorySymlinks = (
	directory: string,
	bundleDir: string,
): void => {
	for (const entry of fs.readdirSync(directory, {withFileTypes: true})) {
		const entryPath = path.join(directory, entry.name);
		if (entry.isSymbolicLink()) {
			if (fs.statSync(entryPath).isDirectory()) {
				throw new Error(
					`The bundle directory ${bundleDir} contains a symbolic link to a directory at ${path.relative(bundleDir, entryPath)}. Directory symbolic links are not supported by \`deploySiteFromBundle()\`.`,
				);
			}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-run the bundle step cleanly (`npx remotion bundle`) and do not hand-edit index.html.
  2. Inspect index.html for the remotion_publicPath line and confirm the value is a properly JSON-quoted string ending in a semicolon.
  3. If using a custom bundling wrapper, ensure it does not rewrite or escape that line.

Example fix

// no code-level fix; rebuild the bundle:
// $ npx remotion bundle --props=... entry.ts
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'node:fs'
function assertPublicPathParses(bundleDir) {
  const html = fs.readFileSync(`${bundleDir}/index.html`, 'utf8')
  const m = html.match(/window\.remotion_publicPath\s*=\s*("(?:[^"\\]|\\.)*")\s*;/)
  if (m) JSON.parse(m[1]) // throws if malformed
}

Try / catch

try {
  await deploySiteFromBundle({bucketName, region, bundleDir})
} catch (e) {
  if (/Could not parse `window.remotion_publicPath`/.test(e.message)) {
    // rebuild the bundle and retry
  } else throw e
}

Prevention

When it happens

Trigger: Bundling produced an index.html whose remotion_publicPath line has an unescaped quote, truncated string, or other JSON-invalid content; manually editing index.html after bundling; filesystem corruption or partial write of the bundle.

Common situations: Hand-editing the bundle output; a custom bundling pipeline that rewrites index.html; transferring the bundle through a tool that mangled quotes; partial/aborted bundle write.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/0ae60b81f229cc3c. Report an issue: GitHub.