remotion-dev/remotion · error · Error
Cannot find file for composition in project
Error message
Cannot find file for composition in project
What it means
The route must determine which file registers the composition: either resolved from newComposition.symbolicatedStack via resolveFilePathFromSymbolicatedStack, or falling back to the project's rootFile from getProjectInfo. If resolution yields null, the composition's registration file cannot be located within the project and the insertion aborts.
Solutions
- Verify the correct entryPoint is passed and that the project's Root file exists
- Check that files referenced by the symbolicated stack still exist in the project
- Re-run the Studio's project info resolution (restart Studio) to refresh getProjectInfo
Example fix
// ensure Root registration file exists // before: entryPoint points at src/missing.tsx // after: entryPoint = 'src/index.ts' which imports <Composition> from './Root'
Defensive patterns
Strategy: validation
Validate before calling
const info = await getProjectInfo(remotionRoot, entryPoint);
if (!info.rootFile) throw new Error('no Root file found for entryPoint: ' + entryPoint); Try / catch
try {
await insertElement(payload);
} catch (e) {
if (/Cannot find file for composition in project/.test(e.message)) {
// verify entryPoint and Root file, then retry
}
} Prevention
- Confirm the entryPoint points at the file that renders <Composition>/<Folder> registrations
- Keep Root files inside the project and avoid deleting referenced files
- Restart Studio to refresh project info after structural changes
When it happens
Trigger: POSTing to insert-element where the symbolicated stack cannot be resolved to an existing project file and getProjectInfo returns a null rootFile (e.g. no Root file found at the entry point).
Common situations: entryPoint pointing at the wrong file, project misconfiguration so no root file is detected, or source maps/symbolicated stack entries referencing files outside the project (deleted or renamed files).
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Asset was not found in public/.
- Cannot create because it already exists
- Component-owned Element initial props must not override…
- Component-owned Element initial style must be an object
- Element source file conflicts with the new composition file
AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18).
Data as JSON: /api/errors/8e13f534875457b9.
Report an issue: GitHub.
Appendix: source
Thrown at packages/studio-server/src/preview-server/routes/insert-element.ts:145
registrationFileNewContents: string;
} | null = null;
let sourceFileOverrides: ReadonlyMap<string, string> | null = null;
if (newComposition !== null) {
if (newComposition.codemod.newId !== compositionId) {
throw new Error(
'New composition ID does not match installation target',
);
}
const registrationFilePath = newComposition.symbolicatedStack
? resolveFilePathFromSymbolicatedStack(
remotionRoot,
newComposition.symbolicatedStack,
)
: (await getProjectInfo(remotionRoot, entryPoint)).rootFile;
if (registrationFilePath === null) {
throw new Error('Cannot find file for composition in project');
}
checkIfTypeScriptFile(registrationFilePath);
if (
path.resolve(remotionRoot, compositionFile) !== registrationFilePath
) {
throw new Error(
'New composition source does not match installation target',
);
}
const componentFilePath = path.join(
path.dirname(registrationFilePath),
`${newComposition.codemod.componentName}.tsx`,
);
if (existsSync(componentFilePath)) {
throw new Error(
`Cannot create ${path.relative(View on GitHub (pinned to 46a3a6bf13)