remotion-dev/remotion · error · Error

Could not locate the JSX reorder target

Error message

Could not locate the JSX reorder target

What it means

Thrown by getMoveSourceEdits (folder-source-edits.ts:454) when a move's destination is a positional reorder (before/after a sibling) but no direct JSX child matches destination.target. The codemod needs the neighbor element's node to compute an adjacent insertion edit; without it the reorder cannot be placed.

Solutions

  1. Confirm the target sibling composition/folder exists as a literal direct JSX child with the expected id/name
  2. Reload the Studio so it re-reads the Root file and retry the reorder
  3. Reorder the elements manually by moving JSX lines in the editor

Example fix

// before (target rendered dynamically, not locatable)
{renderComp('TargetComp')}

// after (literal sibling the codemod can anchor to)
<Composition id="TargetComp" component={TargetComp} ... />
Defensive patterns

Strategy: validation

Validate before calling

const target = locateDirectChild(input, codeMod.destination.target);
if (!target) throw new Error('Reorder target sibling not found as a literal JSX child');

Try / catch

try {
  editFolderInSource({codeMod, input});
} catch (e) {
  if (e instanceof Error && e.message === 'Could not locate the JSX reorder target') {
    // fall back to manual reordering of JSX lines
  }
}

Prevention

When it happens

Trigger: A move-composition-or-folder codemod with destination type 'before'/'after' whose target descriptor (composition id or folder name+parent) matches no direct JSX child in the parsed file — the target sibling was removed, renamed, moved, or is not a literal JSX child.

Common situations: Reordering in the Studio timeline while another client/editor concurrently modified the Root file; the target item is rendered via a variable or helper so it is not a directJsxChild; stale Studio state after renaming the target composition.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18). Data as JSON: /api/errors/383d27be40312e1b. Report an issue: GitHub.

Appendix: source

Thrown at packages/studio-codemods/src/folder-source-edits.ts:454

		insertionEdit = getInsertionRootSourceEdit({
			input,
			insertion,
			root: destination.node as never,
			nullRoot: null,
			prettierConfigOverride: null,
			insertInside: true,
		});
	} else {
		const {destination} = codeMod;
		const target =
			items.find(
				(item) =>
					item.directJsxChild &&
					matchesItem({item: destination.target, located: item}),
			) ?? null;
		if (target === null) {
			throw new Error('Could not locate the JSX reorder target');
		}

		insertionEdit = getAdjacentJsxInsertionSourceEdit({
			input,
			insertion,
			position: destination.type,
			target: target.node,
		});
	}

	return [getNodeSourceEdit({input, jsxPath: source.path}), insertionEdit];
};

export const editFolderInSource = ({
	codeMod,
	input,
}: {
	codeMod: FolderCodemod;

View on GitHub (pinned to 46a3a6bf13)