remotion-dev/remotion · error
Could not find ${getCompositionOrFolderLabel(transformation.
Error message
Could not find ${getCompositionOrFolderLabel(transformation.destination.target)} as a reorder target What it means
moveCompositionOrFolder applies a codemod transformation that reorders a composition or folder relative to a named target. Before mutating the AST it walks the JSX tree to locate the source item and the reorder target. If the destination is 'before' or 'after' but no JSX element matching transformation.destination.target exists as a direct child, this error is thrown because the reorder cannot be performed.
Source
Thrown at packages/studio-codemods/src/recast-mods.ts:650
visitJSXElement(astPath) {
visitJsxElement(astPath as unknown as recast.types.NodePath);
return false;
},
});
if (source === null) {
throw new Error(
`Could not find ${getCompositionOrFolderLabel(transformation.source)} as a direct JSX child`,
);
}
const sourceItem = source as LocatedItem;
if (
(transformation.destination.type === 'before' ||
transformation.destination.type === 'after') &&
target === null
) {
throw new Error(
`Could not find ${getCompositionOrFolderLabel(transformation.destination.target)} as a reorder target`,
);
}
if (
transformation.destination.type === 'folder' &&
destinationFolder === null
) {
const folderPath = [
transformation.destination.parentName,
transformation.destination.folderName,
]
.filter(Boolean)
.join('/');
throw new Error(`Could not find folder "${folderPath}"`);
}
if (target !== null && (target as LocatedItem).node === sourceItem.node) {View on GitHub (pinned to a6a7485a9a)
Solutions
- Check that the target composition/folder name in the transformation destination exactly matches an existing direct JSX child (folder wrapper or composition element) in the file
- Re-read the composition file and regenerate the transformation from current studio state instead of cached state
- If the target may be absent, skip the move or fall back to destination.type 'root' instead of 'before'/'after'
Example fix
// before
await applyCodemod({transformation: {source: {...}, destination: {type: 'after', target: {type: 'composition', name: 'OldName'}}}});
// after
// verify the target exists first, or use the current name
await applyCodemod({transformation: {source: {...}, destination: {type: 'after', target: {type: 'composition', name: 'NewName'}}}}); Defensive patterns
Strategy: validation
Validate before calling
const names = collectDirectChildNames(compositionAst);
if (!names.includes(targetName)) throw new Error(`Reorder target "${targetName}" not found in file`); Type guard
const hasTarget = (items: {name: string}[], target: string) => items.some((i) => i.name === target); Try / catch
try {
await applyCodemod({transformation});
} catch (e) {
if (String(e).includes('as a reorder target')) {
// fall back: move to root or skip
} else throw e;
} Prevention
- Regenerate transformations from freshly read composition state, never cached names
- Verify the target is a direct JSX child of the same parent as the source
- Handle renames by updating transformation targets when compositions are renamed
When it happens
Trigger: Calling applyCodemod with a move transformation whose destination.type is 'before' or 'after' and whose destination.target (composition/folder name) does not match any direct JSX child in the composition file — e.g. the target composition was renamed, deleted, lives in a different folder, or the name was mistyped.
Common situations: Stale studio state after a composition was renamed on disk while the codemod request still references the old name; hand-written codemod scripts with a wrong target name; target nested inside a folder rather than being a direct sibling of the source.
Related errors
- Could not find a root JSX element
- Could not find ${getCompositionOrFolderLabel(transformation.
- Could not find folder "${folderPath}"
- The reorder target is no longer available
- Could not find target folder
AI-assisted analysis of remotion-dev/remotion@a6a7485a9a (2026-09-02).
Data as JSON: /api/errors/f58de70842335227.
Report an issue: GitHub.