remotion-dev/remotion · error
Could not locate the new folder
Error message
Could not locate the new folder
What it means
Thrown at the end of getNewFolderSourceEdits (folder-source-edits.ts:216) when the recast traversal found the codemod's newly grafted `<Folder>` node nowhere: `insertionEdit` stayed null. It means the AST transformation reported a change but no JSX element containing the un-located inserted Folder child could be found to generate a text edit from.
Solutions
- Reload Studio / re-read the Root file and retry creating the folder
- Verify the file does not already contain the folder (duplicate insertion aborts the edit)
- Add the <Folder name="..."> wrapper manually around the target compositions
Defensive patterns
Strategy: try-catch
Validate before calling
if (getLocatedItemsFromSource(input).some(isFolderNamed(codeMod))) {
return; // folder already present; nothing to create
} Try / catch
try {
editFolderInSource({codeMod, input});
} catch (e) {
if (e instanceof Error && e.message === 'Could not locate the new folder') {
// retry once after reloading the file, else instruct manual edit
}
} Prevention
- Don't trigger duplicate new-folder actions for the same name
- Keep the <Folder> insertion point as a literal JSX child
- Reload Studio state after external file edits
When it happens
Trigger: Calling editFolderInSource with a `new-folder` RecastCodemod where applyCodemod mutated the AST but the visited JSX nodes' children do not contain a location-less JSXElement with a resolvable folder `name` — e.g. the Folder was inserted into a non-traversable node type or the grafted node does not match the finder's shape.
Common situations: A stale Studio state where the folder was already created, or Root files where the parent element under which the folder is added is expressed in a way recast's visit cannot re-enter (spreads, conditional expressions).
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Could not find a root JSX element
- Could not find folder
- Could not find target folder
- Could not locate the destination folder
- Could not locate the folder to rename
AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18).
Data as JSON: /api/errors/8f3cbdc9f3477388.
Report an issue: GitHub.
Appendix: source
Thrown at packages/studio-codemods/src/folder-source-edits.ts:216
insertionEdit = getInsertionRootSourceEdit({
input,
insertion: printInsertedJsx({
element: inserted as never,
input,
prettierConfigOverride: null,
}),
root: root as never,
nullRoot: null,
prettierConfigOverride: null,
insertInside: Boolean(jsxNode.loc),
});
return false;
},
});
if (insertionEdit === null) {
throw new Error('Could not locate the new folder');
}
return [
insertionEdit,
...getInsertImportSourceEdits({
ast,
input,
snapshots,
prettierConfigOverride: null,
}),
];
};
const getFolderNameAttribute = (folder: JSXElement) => {
const attribute = folder.openingElement.attributes.find(
(candidate) =>
candidate.type === 'JSXAttribute' &&
candidate.name.type === 'JSXIdentifier' &&View on GitHub (pinned to 46a3a6bf13)