"use node" is present in node runtime file but still getting "you are using node APIs" error
In a file in which I only use actions, I'm trying to use the mailchimp npm package:
I've tried:
- putting
"use node";
at the top of the file, at the top of the imported file, and every variation thereof
- putting all the Mailchimp import and classes I've created in the same file
- No other files import the mailchimp node package
- Deleting the _generated
folder and re-building
- I've added the mailchimp package as an external dependency in convex.json
, and then tried *
to no avail:
Yet I'm still getting this error:
Here is my Mailchimp file:
Any ideas?5 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Are you importing that class into a file that doesn't have
"use node"
? Has to be node all the way down.Often this is because another file in the convex directory is importing the node library (mailchimp) or another file in the convex directory imports this mailchimpActions file
Yeah I have node in all of them.
Thank you both! @Tom i will tripppple check – I suspect this is the culprit.
Wha'ts really weird is that this was all working –– I was using this package for the last few months.
But also, to be fair, the mailchimp package is a bit of a mess and is not typescript, so I've been cajoling it to work. To get a better experience overall, I just generated a new schema & client from an openAPI spec and a created my own client for it. 🙂
Thanks so much guys
OH I guess it'd be ideal to have that error message show the import trace, if possible. E.g., "a node runtime file (mailchimp.ts) is being imported by a non-node runtime bundle: myCrazyMutations.ts"
Yeah I want to do this! We'd try bundling each file in turn to see which ones hit it