convex-backend icon indicating copy to clipboard operation
convex-backend copied to clipboard

Convex deploy problem on nextjs apps

Open devLeopar opened this issue 6 months ago • 4 comments

Hi; There seems a bug happening on while deploying convex on either locally or when trying to deploy on vercel. The documentation suggest using custom build command which is npx convex deploy --cmd 'npm run build'

However, this command fails generating convex/_generated folder before nextjs try to build whole app. Therefore, it results in 'module not found' errors on the files that imports modules from this folder.

I found a solution. If we ignore --cmd option and update the custom build command like below: npx convex deploy && npm run build It waits convex to deploy and generate related folder and files, then run next build.

My suggestion is updating documentation which is here: https://docs.convex.dev/production/hosting/vercel

devLeopar avatar May 22 '25 22:05 devLeopar

Can you provide repro steps? Like what is an example app (ideally one of the Convex demo apps) and add screenshots / exact information from the errors you are seeing.

Thanks for the reprot.

nipunn1313 avatar May 22 '25 22:05 nipunn1313

@nipunn1313 I've created a PR for this and explained a bit more

devLeopar avatar May 22 '25 22:05 devLeopar

The issue is probably the docs saying npm convex deploy --cmd 'npm run build' but you can see in the screenshot that it actually is npm convex deploy --cmd='npm run build' with = after --cmd. I guess this is the issue because I'm using = for my project and have no issue deploying.

wkd-kapsule avatar May 25 '25 01:05 wkd-kapsule

Either syntax is allowed, these are both valid parsings. It sounds like the problem is you don't want to commit the convex/_generated directory, so you need to generate it each time? I suggest trying convex codegen && npx convex deploy --cmd 'npm run build' for this. Generally the _convex/generated directory is committed to version control so this isn't an issue.

thomasballinger avatar Jun 02 '25 21:06 thomasballinger