Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Use npm package mode for copied CLI command

Cursor Agent24c40d6b933d
diff --git a/packages/studio/src/components/RenderModal/ServerRenderModal.tsx b/packages/studio/src/components/RenderModal/ServerRenderModal.tsx
index 0c2c862d01..f5c30698a5 100644
--- a/packages/studio/src/components/RenderModal/ServerRenderModal.tsx
+++ b/packages/studio/src/components/RenderModal/ServerRenderModal.tsx
@@ -1342,10 +1342,9 @@ const RenderModal: React.FC<
</div>
{readOnlyStudio ? (
<div style={readOnlyHint}>
- Copies a command pinned to your Studio version using{' '}
- <code>{`npx remotion@${window.remotion_version}`}</code>. If{' '}
- <code>@remotion/cli</code> is not installed locally, <code>npx</code>{' '}
- will download the matching version.
+ Copies an npm command that works without a local Remotion install. It
+ uses <code>{`@remotion/cli@${window.remotion_version}`}</code> to
+ match this Studio version.
</div>
) : null}
<div style={horizontalLayout}>
diff --git a/packages/studio/src/helpers/make-render-command.ts b/packages/studio/src/helpers/make-render-command.ts
index 1ffcb6ba3a..b3654d6197 100644
--- a/packages/studio/src/helpers/make-render-command.ts
+++ b/packages/studio/src/helpers/make-render-command.ts
@@ -26,8 +26,10 @@ const addBooleanFlag = (flags: string[], flag: string, value: boolean) => {
}
};
-export const makeVersionedRemotionCommandPrefix = (version: string) => {
- return version.trim() === '' ? 'npx remotion' : `npx remotion@${version}`;
+export const getNpmRemotionCommandPrefix = (version: string) => {
+ return version.trim() === ''
+ ? 'npx -p @remotion/cli remotion'
+ : `npx -p @remotion/cli@${version} remotion`;
};
export const normalizeServeUrlForRenderCommand = ({
@@ -114,7 +116,7 @@ export const makeReadOnlyStudioRenderCommand = ({
compositionId,
});
const commandType = renderMode === 'still' ? 'still' : 'render';
- const command = makeVersionedRemotionCommandPrefix(remotionVersion);
+ const command = getNpmRemotionCommandPrefix(remotionVersion);
const {options} = BrowserSafeApis;
const flags: string[] = [];
diff --git a/packages/studio/src/test/make-render-command.test.ts b/packages/studio/src/test/make-render-command.test.ts
index 90b6062ae8..9ebd894f23 100644
--- a/packages/studio/src/test/make-render-command.test.ts
+++ b/packages/studio/src/test/make-render-command.test.ts
@@ -1,8 +1,8 @@
import {expect, test} from 'bun:test';
import type {RenderDefaults} from '@remotion/studio-shared';
import {
+ getNpmRemotionCommandPrefix,
makeReadOnlyStudioRenderCommand,
- makeVersionedRemotionCommandPrefix,
normalizeServeUrlForRenderCommand,
} from '../helpers/make-render-command';
@@ -52,11 +52,11 @@ const getDefaults = (): RenderDefaults => {
};
};
-test('Should pin remotion version in command prefix', () => {
- expect(makeVersionedRemotionCommandPrefix('4.0.431')).toBe(
+test('Should map to npm-based command prefix', () => {
+ expect(getNpmRemotionCommandPrefix('4.0.431')).toBe(
+ 'npx -p @remotion/[email protected] remotion',
);
- expect(makeVersionedRemotionCommandPrefix('')).toBe('npx remotion');
+ expect(getNpmRemotionCommandPrefix('')).toBe('npx -p @remotion/cli remotion');
});
test('Should normalize serve URL by stripping selected composition', () => {
@@ -106,7 +106,7 @@ test('Should generate concise read-only render command and omit concurrency', ()
});
expect(command).toContain(
- "npx [email protected] render 'https://example.com' 'dynamic-length'",
+ "npx -p @remotion/[email protected] remotion render 'https://example.com' 'dynamic-length'",
);
expect(command).toContain("--frames='10-80'");
expect(command).toContain('--muted');
@@ -146,7 +146,7 @@ test('Should generate still command and omit default flags', () => {
});
expect(command).toContain(
- "npx [email protected] still 'https://example.com/still' 'StillComp'",
+ "npx -p @remotion/[email protected] remotion still 'https://example.com/still' 'StillComp'",
);
expect(command).toContain("--frame='12'");
expect(command).not.toContain("--image-format='png'");