remotion-dev/remotion · error · Error
outputLocation must be a string but got ${typeof newOutputLo
Error message
outputLocation must be a string but got ${typeof newOutputLocation} (${JSON.stringify(newOutputLocation)}) What it means
`Config.setOutputLocation()` validates that its argument is a string at runtime; any non-string throws an Error that echoes both the JS type and JSON representation of the value. The setter stores the final output path used by render/still when the user wants to override the CLI-supplied path.
Source
Thrown at packages/cli/src/config/output-location.ts:5
let currentOutputLocation: string | null = null;
export const setOutputLocation = (newOutputLocation: string) => {
if (typeof newOutputLocation !== 'string') {
throw new Error(
`outputLocation must be a string but got ${typeof newOutputLocation} (${JSON.stringify(
newOutputLocation,
)})`,
);
}
if (newOutputLocation.trim() === '') {
throw new Error(`outputLocation must not be an empty string`);
}
currentOutputLocation = newOutputLocation;
};
export const getOutputLocation = () => currentOutputLocation;
export const resetOutputLocation = () => {
currentOutputLocation = null;
};View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Make sure the value is always a string before calling: provide a fallback or assert the env var is set.
- Coerce explicitly only if the input truly is string-like: `Config.setOutputLocation(String(value))`.
Example fix
// before Config.setOutputLocation(process.env.OUT); // after Config.setOutputLocation(process.env.OUT ?? 'out/video.mp4');
Defensive patterns
Strategy: type-guard
Validate before calling
const out = process.env.OUT;
if (typeof out !== 'string') {
throw new Error(`OUT must be a string, got ${typeof out}`);
}
Config.setOutputLocation(out); Type guard
const isNonEmptyString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
Prevention
- Always provide a fallback path when sourcing from env.
- Validate at the boundary where untyped data enters the program.
When it happens
Trigger: Calling `Config.setOutputLocation(undefined)`, `Config.setOutputLocation(123)`, `Config.setOutputLocation(null)`, or `Config.setOutputLocation({path: '...'})`.
Common situations: Reading a path from env (`process.env.OUT`) that may be undefined; passing a parsed JSON value that came back as a non-string; programmatically building the path with a helper that can return undefined.
Related errors
- setImageSequence accepts a Boolean Value
- outputLocation must not be an empty string
- Studio server port should be a number. Got ${typeof port} ($
- Caching flag must be a boolean.
- Polling must be a number or null, got ${JSON.stringify(
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/4db365d827047e92.
Report an issue: GitHub.