remotion-dev/remotion · error · Error

Config.addElementLibrary() expects the display name to be a

Error message

Config.addElementLibrary() expects the display name to be a string, got ${typeof displayName}

What it means

The optional displayName option must be a string when provided. Passing a number, object, or other type throws with typeof displayName.

Source

Thrown at packages/cli/src/config/element-libraries.ts:45

	}

	let parsedUrl: URL;
	try {
		parsedUrl = new URL(url);
	} catch {
		throw new Error(
			`Config.addElementLibrary() expects an absolute URL, got ${JSON.stringify(url)}`,
		);
	}

	if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
		throw new Error(
			`Config.addElementLibrary() only supports HTTP and HTTPS URLs, got ${JSON.stringify(url)}`,
		);
	}

	if (displayName !== undefined && typeof displayName !== 'string') {
		throw new Error(
			`Config.addElementLibrary() expects the display name to be a string, got ${typeof displayName}`,
		);
	}

	const trimmedDisplayName = displayName?.trim() ?? null;
	if (trimmedDisplayName === '') {
		throw new Error(
			'Config.addElementLibrary() expects the display name to not be empty',
		);
	}

	elementLibraries.push({
		displayName: trimmedDisplayName,
		url: parsedUrl.href,
	});
};

export const getElementLibraries = (): readonly StudioElementLibrary[] =>

View on GitHub (pinned to 8f97758157)

Solutions

  1. Convert displayName to a string before passing, or omit it entirely
  2. Type the options object against the documented signature

Example fix

// before
Config.addElementLibrary({url, displayName: 42});

// after
Config.addElementLibrary({url, displayName: String(42)});
Defensive patterns

Strategy: type-guard

Validate before calling

if (displayName !== undefined && typeof displayName !== 'string') { /* convert or omit */ }

Type guard

const isOptionalString = (v: unknown): v is string | undefined => v === undefined || typeof v === 'string';

Prevention

When it happens

Trigger: Config.addElementLibrary({url, displayName: 42}) or displayName derived from a non-string value.

Common situations: Programmatically building options where displayName comes from untyped data (e.g. package.json metadata).

Related errors


AI-assisted analysis of remotion-dev/remotion@8f97758157 (2026-08-28). Data as JSON: /api/errors/834e34510d419ce9. Report an issue: GitHub.