remotion-dev/remotion · error · Error
The "${nameOfProp}" prop ${location} must be a number, but y
Error message
The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount} What it means
`validateDimension` checks the `width`/`height` of a composition (whether declared on `<Composition>` or returned from `calculateMetadata`). The first check requires a `number` type; any non-number — including `undefined` (which happens when neither the prop nor calculated metadata supplies a dimension) — throws.
Source
Thrown at packages/core/src/validation/validate-dimensions.ts:7
export function validateDimension(
amount: unknown,
nameOfProp: string,
location: string,
): asserts amount is number {
if (typeof amount !== 'number') {
throw new Error(
`The "${nameOfProp}" prop ${location} must be a number, but you passed a value of type ${typeof amount}`,
);
}
if (isNaN(amount)) {
throw new TypeError(
`The "${nameOfProp}" prop ${location} must not be NaN, but is NaN.`,
);
}
if (!Number.isFinite(amount)) {
throw new TypeError(
`The "${nameOfProp}" prop ${location} must be finite, but is ${amount}.`,
);
}
if (amount % 1 !== 0) {
throw new TypeError(View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Provide numeric `width`/`height` on `<Composition>`, or ensure `calculateMetadata` returns them.
- Coerce string sources: `Number(config.width)`.
- Never rely on implicit conversion — strings are not accepted.
Example fix
// before
<Composition width="1920" height="1080" ... />
// after
<Composition width={1920} height={1080} ... /> Defensive patterns
Strategy: type-guard
Validate before calling
if (typeof w !== 'number') {
throw new Error('width must be a number, got ' + typeof w);
} Type guard
const isDimension = (v) => typeof v === 'number' && !Number.isNaN(v);
Prevention
- Always pass numeric literals for width/height.
- Coerce config/env dimensions with Number() and validate.
- Ensure calculateMetadata always returns width and height.
When it happens
Trigger: Setting `width`/`height` to a string (`'1920'`), or leaving both the `<Composition>` prop and the `calculateMetadata` return value unset so that `undefined` reaches the validator.
Common situations: Reading dimensions from URL params, env vars, or a JSON config as strings without coercing; forgetting width/height on a composition that relies on `calculateMetadata` which fails to return them; SSR where metadata resolution returns nothing.
Related errors
- The "${name}" prop ${location} must be a string, but you pas
- "${name}" must be an object, but you passed a value of type
- The "${nameOfProp}" prop ${location} must not be NaN, but is
- The "${nameOfProp}" prop ${location} must be finite, but is
- The "${nameOfProp}" prop ${location} must be an integer, but
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/6456fae2450d784d.
Report an issue: GitHub.