-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: faunadb.Client is not a constructor #668
Comments
Internal ticket number is FE-2896 |
Hi @pieterdd, sorry you ran into this. Do any of the following work for you?
|
Hi Henry, thanks for helping me diagnose this issue. The first approach works on my local development server but yields the following error when deployed:
The second approach, which is also in line with what the error suggests, does not get accepted by TypeScript on my machine. The error reads:
|
Hi @pieterdd have you figured this out? I acknowledge it has been quite some time since you created the issue. Have you tried setting the following in your "esModuleInterop": true,
"moduleResolution":"node", |
I haven't, so I added the lines to
|
FWIW, I bumped into vitejs/vite#4680. It looks like CommonJS modules and Vite ( |
Are there any updates on this? Importing the library into an ESM project still errors. "dependencies": {
"fauna": "npm:faunadb@^4.8.0"
} import * as Fauna from "fauna"; client: new Fauna.Client({
secret: process.env.FAUNA_SECRET!,
domain: "db.us.fauna.com",
scheme: "https",
port: 443,
}), TypeError: Fauna.Client is not a constructor
at createDatabase (c:\Users\Administrator\Documents\Programming\Projects\Private\logos\src\lib\database\database.ts:251:11)
at createClient (c:\Users\Administrator\Documents\Programming\Projects\Private\logos\src\lib\client.ts:145:13)
at initialiseClient (c:\Users\Administrator\Documents\Programming\Projects\Private\logos\src\lib\client.ts:168:17)
at initialise (c:\Users\Administrator\Documents\Programming\Projects\Private\logos\src\initialise.ts:185:9) |
I use fauna with Cloudflare pages, therefore I have a
And here is how I use fauna within my edge functions
Hope this could help someone. |
Is there a known workaround to use Client class in an ESM module? |
I got this to work in ESM code by using |
I'm trying to use faunadb in a codebase that uses ES Module syntax and I get this:
Curiously, this happens when a Vite-powered SvelteKit codebase is deployed on Netlify/Vercel, but works without issue on my local machine. This is my import line:
I constructed the object like this:
The text was updated successfully, but these errors were encountered: