Open AsyncFox opened 10 months ago
Hi @AsyncFox, this might be related to the fact that cloudflare doesn't support the postgres
package, could you try with pg
? https://developers.cloudflare.com/workers/databases/connect-to-postgres/#requirements
This is because workerd doesn't support TCP and needs a compatible driver to connect to postgres instances.
Hi @Hebilicious , I tried pg
but when using nuxi build
it generates a new error. I found a discussion post related to this but it was not helpful to this situation. But anyway, thanks for your reach out, I have temporarily moved to vercel for deployment.
[nitro 22:47:00] ERROR Error: Cannot resolve "pg-native" from "\\node_modules\\.pnpm\\pg@8.11.3\\node_modules\\pg\\lib\\native\\client.js" and externals are not allowed!
Hi @Hebilicious , I tried
pg
but when usingnuxi build
it generates a new error. I found a discussion post related to this but it was not helpful to this situation. But anyway, thanks for your reach out, I have temporarily moved to vercel for deployment.Logs
[nitro 22:47:00] ERROR Error: Cannot resolve "pg-native" from "\\node_modules\\.pnpm\\pg@8.11.3\\node_modules\\pg\\lib\\native\\client.js" and externals are not allowed!
I tried building your project on stackblitz by swapping out postgres for pg and did not encounter a build error.
Are you able to build with pg for vercel
, but not for cloudflare-pages
?
Are you able to build with pg for
vercel
, but not forcloudflare-pages
?
Yes, that's right. Building for vercel
works fine, but not for cloudflare-pages
Environment
Nuxt 3.7 Nitro 2.6.2 Cloudflare Wrangler 3.6.0
Reproduction
StackBlitz: https://stackblitz.com/github/AsyncFox/nuxt-trpc-drizzle-repro Github repo: https://github.com/AsyncFox/nuxt-trpc-drizzle-repro
Describe the bug
After
nuxi build
, I triedwrangler pages dev dist/
to run locally, but it shows an error. I also tried deploy to cloudflare pages but it also failed. Usingnuxi dev
works fine.Additional context
I am using trpc-nuxt and drizzle-orm. If you remove other procedures and only reserve
hello
procedure inserver\trpc\routers\index.ts
, it works fine. I guess it is also drizzle-orm related becausehello
procedure does not require any db operation.Logs
And on cloudflare pages: