deploying mono repo with vercel
trying to deploy the monorepo using vercel
imagine I will have to manually do the steps related to expo and the app deploy, but hoping to get vercel to deploy the web app
11 Replies
first question what should the command be
got this error
✖ In order to push, add
convex to your package.json dependencies.
Error: Command "npx convex deploy --cmd 'npm run build'" exited with 1
get this log
Running 'npm run build' with environment variable "CONVEX_URL" set...
instead of
- Running 'npm run build' with environment variable "NEXT_PUBLIC_CONVEX_URL" set...You could try to cd into the project directory for the convex backend (the parent directory of your
convex
folder), in the build command, before running npx convex deploy
.I’ll try that
npx convex deploy --cmd 'npm run build; cd packages/backend’
The problem seems to be that its setting CONVEX_URL and not NEXT_PUBLIC_CONVEX_URL
cd packages/backend && npx convex deploy --cmd 'npm run build'
that's what I'd do.
You can specify the env var name:
cd packages/backend && npx convex deploy --cmd 'npm run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
see docs: https://docs.convex.dev/cli#deploy-convex-functions-to-productionCLI | Convex Developer Hub
The Convex command-line interface (CLI) is your interface for managing Convex
Thank you
now it says its deployed
Deployed Convex functions to https://tame-condor-52.convex.cloud
but I don't see any functions there on the convex dashboard
Do you have the right deployment selected on the dashboard? The tame-condor-52 should show up in the URL.
Also there's a History tab and Logs page, they would show the deployment.
✔ Ran "npm run build" with environment variable "NEXT_PUBLIC_CONVEX_URL" set
- Deploying to https://tame-condor-52.convex.cloud...
✔ Deployed Convex functions to https://tame-condor-52.convex.cloud'
deployment history is only avialable on paid planslocally
this
/: npx convex deploy --cmd 'npm run build; cd packages/backend' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
erases all the functions in convex
but
/packages/backend:npm run build && cd packages/backend && npx convex deploy --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
works
got this to work, but my command basically has to build the code twice
npx convex deploy --cmd 'npm run build' --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL && cd packages/backend && npx convex deploy --cmd-url-env-var-name NEXT_PUBLIC_CONVEX_URL
Aha, I see you need the URL to build the frontend and then to deploy from the right directory
Your
NEXT_PUBLIC_CONVEX_URL
doesn't change, so you don't need to jump through these hoops. Simply:
1. Set NEXT_PUBLIC_CONVEX_URL
on your hosting provider dashboard
2. Change the command to cd packages/backend && npx convex deploy && cd ../.. && npm run build
NEXT_PUBLIC_CONVEX_URL
is your Convex URL, you can see it on your Convex dashboard (for your prod deployment).
This won't work for preview deployments though, there the URL does change.
For preview deployment you can probably do something like:
cd packages/backend && npx convex deploy --cmd 'echo NEXT_PUBLIC_CONVEX_URL=$CONVEX_URL > ../../.env' && cd ../.. && npm run build
thanks - will try this if I can finish getting the eas expo build to run