Open MickL opened 1 year ago
I havn't try it on edge but will do and try to find the problem, thanks for the issue 👍
Same for Cloudflare, after i installed @aws-sdk/credential-providers the module just required the next dependency, and the next and so on. Do you have any idea what could be the reason for this or have you perhaps already looked into it?
Any news on this issue? Currently this problem blocks all deployments for us, is there a way I could support you to get this work again? Have you already looked into this problem?
@nicokempe I'm so sorry but I don't have experience with edge, so I wasn't successful. I'll ask others, and if you have a solution PR is more than welcome. thanks
Seems like the MongoDB package itself is not edge compatible. The dependencies that make problems are a sub-dependency of MongoDB and I have read on StackOverflow that this is not only known but not really possible without workarounds like a REST Relay...
Vercel itself provides guidelines on making libraries compatible with their Edge Functions runtime. This includes using a subset of Web APIs like fetch, Request, and Response, and avoiding certain Node.js APIs and JavaScript features that are not supported in the Edge Runtime. For MongoDB specifically, it seems like you should use the MongoDB Data API, which is HTTP-based but they say "While it is not a full replacement for the MongoDB driver, it does provide a way to access MongoDB from a browser or edge-computing service like Cloudflare Workers" themselves so I dont know how good of an alternative that is..
I have just joined the unofficial MongoDB community Discord and opened a Ticket at MongoDB and asked if anybody knows if the MongoDB package is going to be edge support because I couldnt find any information about that
References:
@nicokempe Thanks Nico for the information and resources shared but let me ask you for a new update or any other workaround you have found on this issue.
[info] [nitro] Building Nuxt Nitro server (preset: cloudflare-pages
)
[error] [nitro] Error: Cannot resolve "@aws-sdk/credential-providers" from "/opt/buildhome/repo/node_modules/.pnpm/mongodb@6.5.0/node_modules/mongodb/lib/deps.js" and externals are not allowed!
likely the same error ( when deploy using NuxtHub ) so we can not use mongoose on cloudflare pages right?
I have the same error with nuxthub and cloudflare with error call by not resolve something influrrent with "snappy" in mongodb. otherwise If I use cloudflare to start project and install nuxt-mongoose, I got the error call 'Cannot resolve "@aws-sdk/credential-providers'
I have spent to much time for solution of mongoose using on cloudflare. Does have any solution, I got this solution, but I still unclean does it work, look complicated have lots of step to setup.
https://www.mongodb.com/developer/products/atlas/cloudflare-worker-rest-api/
Personally I switched over to use Drizzle + PostgreSQL. On Cloudflare you can use Drizzle + Cloudflare D1 (NoSQL)
Personally I switched over to use Drizzle + PostgreSQL. On Cloudflare you can use Drizzle + Cloudflare D1 (NoSQL)
Seem like sound good, I will try. Thank you MickL for the advise ❤
@whitersun you can try the stack in https://hub.nuxt.com/
@whitersun you can try the stack in https://hub.nuxt.com/
yeah, nuxthub is something very cool, I was using nuxt to storage my data. I just confuse when unable to using mongodb. Hope something like zeabur, able to add mongodb and auto key to management.
@nicokempe Thanks Nico for the information and resources shared but let me ask you for a new update or any other workaround you have found on this issue.
[info] [nitro] Building Nuxt Nitro server (preset:
cloudflare-pages
) [error] [nitro] Error: Cannot resolve "@aws-sdk/credential-providers" from "/opt/buildhome/repo/node_modules/.pnpm/mongodb@6.5.0/node_modules/mongodb/lib/deps.js" and externals are not allowed!
I have seen this just now I am sorry 😅, I have worked a week on the migration to Supabase because I couldn't get it to run on Cloudflare Pages with MongoDB. I am pretty happy with that decision now even though I prefer NoSQL databases like MongoDB over relational databases like PostgreSQL.
Thanks, this plugin looks amazing! It works fine on my local dev but deploying to Vercel Edge Functions I get the following error:
I dont exactly understand why would it even need
@aws-sdk/credential-providers
?It works on my local dev and also when I deploy to normal Vercel (not to Edge Functions using
NITRO_PRESET="vercel-edge"
) it works just fine.