void
void5d ago

Vercel deployment fails when using `npx convex deploy --cmd '...'`

I've overridden the build command in Vercel when adding my project which is a basic Vite/React 19 project using Convex to be npx convex deploy --cmd='vite build' The error is:
✗ Build failed in 800ms
error during build:
Could not resolve "../convex/_generated/api"
✗ Build failed in 800ms
error during build:
Could not resolve "../convex/_generated/api"
However, when I change the build command to npx convex deploy && vite build things seem to work okay. Is this okay or is the --cmd option when calling convex deploy the ideal way?
4 Replies
Convex Bot
Convex Bot5d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Nicolas
Nicolas5d ago
From the error message you sent it looks like the codegen files are missing We recommend that you commit the files in convex/_generated to your version control system (e.g. Git), is it the case in your project?
void
voidOP4d ago
ah; understood. i thought it made sense to add convex/_generated to .gitignore maybe this is an assumption i made from earlier versions of convex
sshader
sshader4d ago
Also the difference between npx convex deploy && npx vite build vs. npx convex deploy --cmd='npx vite build' (aside from deploy adding the generated files) is that the latter will wait to deploy your Convex functions until the --cmd succeeds. If you had an error in the vite build command, the && version would deploy the new version of your Convex functions but then your frontend build would fail and your users would be on an old frontend version but with the new Convex functions

Did you find this page helpful?