cornpopguy
cornpopguy8mo ago

Error while using Plunk with Convex

Hi guys, I am getting the following error while trying to use Plunk with Convex (I am currently migrating from Resend):
[convex:dev]
[convex:dev] ✖ Error: Unable to push deployment config to https://adventurous-mockingbird-762.convex.cloud
[convex:dev] Error fetching POST https://adventurous-mockingbird-762.convex.cloud/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
[convex:dev] Loading the pushed modules encountered the following
[convex:dev] error:
[convex:dev] Uncaught Failed to analyze clerk/emails.js: Plunk is not a constructor
[convex:dev] at <anonymous> (../../src/app/_lib/plunk/context.ts:6:56)
[convex:dev]
[convex:dev] ✖ Error: Unable to push deployment config to https://adventurous-mockingbird-762.convex.cloud
[convex:dev] Error fetching POST https://adventurous-mockingbird-762.convex.cloud/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
[convex:dev] Loading the pushed modules encountered the following
[convex:dev] error:
[convex:dev] Uncaught Failed to analyze clerk/emails.js: Plunk is not a constructor
[convex:dev] at <anonymous> (../../src/app/_lib/plunk/context.ts:6:56)
No description
8 Replies
Michal Srb
Michal Srb8mo ago
What does your code look like? Try to move the Plunk library call inside your action (instead of having it at the module scope, which the error suggests is happening now).
cornpopguy
cornpopguyOP8mo ago
Sorry for reposting here. But the Plunk team already replied before: This is because our NodeJS package is still a classic module. I recommend building your own wrapper function using the API for now!
Michal Srb
Michal Srb8mo ago
What does "classic module" mean. You can also try using Node actions: https://docs.convex.dev/functions/actions#calling-third-party-apis-and-using-npm-packages
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
cornpopguy
cornpopguyOP8mo ago
Yes, I am using it in a action with 'use node';
cornpopguy
cornpopguyOP8mo ago
No description
cornpopguy
cornpopguyOP8mo ago
I creates this file called context.ts so I can reuse it. Just to note I was using Resend the similiar way and it worked. Will try soon. Moving the whole const plunk = new Plunk("Your secret key"); seems to work.
cornpopguy
cornpopguyOP8mo ago
Actually not, I get these errors in Convex logs now:
No description
cornpopguy
cornpopguyOP8mo ago
Will try soon. It means CommonJS module.

Did you find this page helpful?