That flag can only be set with Wrangler

That flag can only be set with Wrangler if you create a project with wrangler afaik, otherwise it needs to be set in the dashboard
9 Replies
Jan Piotrowski (janpio)
My first pages:deploy did create the project, but I assume you mean when uses an explicit "create project" wrangler command?
James
JamesOP•12mo ago
Yeah, so that command is just for deploying, but if you don't have a project yet it will offer you the option to create one, which is slightly different to just running the pages project create command. The create command on the other hand accepts a flag for compatibility flags to create a project with, which is used in the create-cloudflare lib if you let it create the project at the end. npx wrangler pages project create my-app --compatibility-flags=nodejs_compat types message and then proceeds to edit it 6 times because he didn't read it before pressing send
Jan Piotrowski (janpio)
Ok, understood. It's another one of those thing that confuses a bit and takes a few minutes to figure out. (In my case it usually does not show the helpful error message that nodejs_compat immediately, but first the deployment URLs just do not work for a few minutes. Not sure why that is.)
James
JamesOP•12mo ago
The deployment urls not working for a few minutes could be due to provisioner lag deploying the worker for the site. Yeah, it's been a constant frustration when people first use the library, but sadly is something that is challenging to do something about. It's mentioned in the docs, but obviously that can be easy to miss when skimming through
Jan Piotrowski (janpio)
https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/ does not mention pages:deploy, just other approaches to deploy. Or am I overlooking it?
James
JamesOP•12mo ago
Correct, the docs don't really touch on the package.json scripts created by create-cloudflare, but that's definitely an area they probably should
Jan Piotrowski (janpio)
Deploy via the create-cloudflare CLI (C3) If you use create-cloudflare(C3) to create your new Next.js project, C3 will install all dependencies needed for your project and prompt you to deploy your project via the CLI. If you deploy, your site will be live and you will be provided with a deployment URL.
If I connect the dots correctly, this is actually the approach I am using - I got this project via npm create cloudflare@latest my-next-app -- --framework=next. So that is probably where both the command and also the requirement to manually set the nodejs_compat flag could be mentioned. Although there is duplication with similar instructions under "Deploy via the Cloudflare dashboard" - but of course I just skipped that because I do not want to connect Git and then deploy via the UI.
James
JamesOP•12mo ago
When you used npm create cloudflare, did you deploy when the CLI prompted you to, or was your first deploy using pages:deploy? If you deployed when the CLI prompted you at the end, it should set the compat flag automatically for the new project, if you deploy with pages:deploy and it creates the project that way, you would need to set it manually. Definitely clarification worthy. To be honest, most of this article was quickly updated when we released v1 of next-on-pages, so it's kind of on me for not putting enough info when I did that 🙈
Jan Piotrowski (janpio)
I skipped the initial deployment, as I knew I had to actually put something useful in there first 😄
Want results from more Discord servers?
Add your server