remotion-dev/remotion · error
The reorder target is no longer available
Error message
The reorder target is no longer available
What it means
After locating the reorder target, moveCompositionOrFolder removes the source element from its parent's children array and splices it before/after the target. If the target element is no longer found in its recorded parent's children array at splice time (indexOf returns -1), this error is thrown — meaning the AST changed between locating the target and performing the splice.
Source
Thrown at packages/studio-codemods/src/recast-mods.ts:728
);
}
}
const sourceReturnStatement = getEnclosingReturnStatement(sourceItem.path);
deleteJsxElementAtPath(sourceItem.path);
const element = stripParenthesizedExtra(sourceItem.node);
if (transformation.destination.type === 'root') {
appendElementToRoot({element, returnStatement: sourceReturnStatement});
} else if (transformation.destination.type === 'folder') {
appendElementToFolder({
element,
folderElement: (destinationFolder as unknown as LocatedItem).node,
});
} else {
const targetItem = target as unknown as LocatedItem;
const targetIndex = targetItem.parent.children.indexOf(targetItem.node);
if (targetIndex === -1) {
throw new Error('The reorder target is no longer available');
}
targetItem.parent.children.splice(
transformation.destination.type === 'before'
? targetIndex
: targetIndex + 1,
0,
element,
);
}
changesMade.push({description: 'Moved composition or folder'});
return {newAst: file, changesMade};
};
const moveCompositionToFolder = ({
file,
transformation,View on GitHub (pinned to a6a7485a9a)
Solutions
- Re-run the codemod against a freshly parsed file so all targets are located against current state
- Ensure batched transformations do not remove or move each other's targets
- Apply transformations sequentially, re-reading the file between each
Example fix
// before applyCodemods([moveAAfterB, removeB]); // removeB invalidates moveAAfterB's target // after applyCodemods([removeB]); applyCodemods([regenerateAndMoveAAfterSiblingOfB]); // recompute target after B is gone
Defensive patterns
Strategy: retry
Validate before calling
// after each transformation, re-parse before computing the next one const ast = parse(readFileSync(compositionFile, 'utf8'));
Try / catch
try {
await applyCodemod({transformation});
} catch (e) {
if (String(e) === 'Error: The reorder target is no longer available') {
await applyCodemod({transformation: regenerateTransformation(freshParse())}); // retry with fresh state
} else throw e;
} Prevention
- Re-parse the file between batched transformations so targets are located against current state
- Avoid batching transformations that remove or move each other's targets
- Serialize all writes to a composition file (single write queue) to prevent concurrent mutation
When it happens
Trigger: The target's parent children array does not contain targetItem.node, typically because a prior transformation in the same applyCodemod batch already removed or re-parented the target element, or the same node was matched at two locations.
Common situations: Batched codemods where an earlier move deleted/moved the target; conflicting overlapping transformations; concurrent edits to the composition file during codemod execution.
Related errors
- Could not find a root JSX element
- Could not find ${getCompositionOrFolderLabel(transformation.
- Could not find ${getCompositionOrFolderLabel(transformation.
- Could not find folder "${folderPath}"
- Could not find target folder
AI-assisted analysis of remotion-dev/remotion@a6a7485a9a (2026-09-02).
Data as JSON: /api/errors/1ac0097ec919afd4.
Report an issue: GitHub.