Build error with @blocknote/server-util (local dev)
I need to run the following function in an action:
I get the following error:
The file where the action is declared is marked with "use node" directive.
How do I make it work? Thanks.
14 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!
The file where the action is declared is marked with "use node" directive.Is the function you listed above in the same file as the action? If not, try adding the "use node" directive there as well. Not 100% sure if this will change anything, but it might be worth a try. I'm in the early stages of adding a feature that sounds similar to yours, and the file where I need an extra package is separate from the file containing the action that will call it. I might get to testing that today, and I'll let you know what I find.
@Clever Tagline thanks for your advice, but unfortunately it doesn't help. I even moved the function together with
@blocknote/server-util
import into the file with actions and still getting the error.Thanks for the update. I'm not yet at a point where I can test my setup.
Out of curiosity, is this a local Convex deployment or a cloud deployment?
@Clever Tagline local
Gotcha. Unfortunately I don't have experience self-hosting Convex, and something tells me that might play into this issue. If you haven't already done so, I recommend posting in the #self-hosted channel. I'll update the title of this post as well, and perhaps between the two someone can help you figure this out.
Local as in you selected local dev but you're still using the cloud product/dashboard, or local as in self-hosted, where you run a docker container with your convex deployment?
In either case, though, this is likely a bug that would also happen in the cloud offering. Can you share more of the relevant code, like the action that calls the node action, and the node action itself?
I meant to say “self-hosted,” but my brain couldn’t generate the phrase at the time. Must’ve given it the wrong prompt. 😣
@erquhart yes, "selected local dev but using the cloud product/dashboard". There's actually no more code to share. I get this error when trying to build the app (convex dev). I don't have an action to trigger this yet.
I thought this happens because @blocknote/server-util or it's dependency jsdom that actually triggers build error are not compatible with node 18 which is required for local development, but this seems not to be the case:
https://www.npmjs.com/package/@blocknote/server-util?activeTab=code - depends on jsdom 25.0.1
https://www.npmjs.com/package/jsdom/v/25.0.1?activeTab=code - has "node": ">=18"
The code you shared, is it in a file with the "use node" directive at the top?
@erquhart yes, it is in a file with "use node" directive
Try adding jsdom to externalPackages: https://docs.convex.dev/functions/bundling#specifying-external-packages
@erquhart adding
jsdom
to externalPackages gives the same error as in my initial message in this thread. Adding @blocknote/server-util
fails with
Don't add @blocknote/server-util to externals. Maybe jsdom and canvas together - this issue seems to be common with jsdom and esbuild (which convex uses underneath), some folks used patches but hopefully externals can be enough: https://github.com/evanw/esbuild/issues/1311#issuecomment-2766631083
The issue is four years old but comments are still coming in from folks affected