Jakeyjuju
Jakeyjujuā€¢8mo ago

Unable to import node:fs

I'm trying to modify a local convex project to write to a file, but when I import node:fs I get this error: The package "node:fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. I've tried adding fs to Node_modules but it still returns the same error. Sorry if this is a dumb question, I'm new to convex and not really sure what the procedure is for importing stuff is.
4 Replies
erquhart
erquhartā€¢8mo ago
Welcome! You would need to use node to access libraries that aren't compatible with the convex runtime: https://docs.convex.dev/functions/runtimes#nodejs-runtime That said, your Convex functions are serverless functions that won't have a filesystem to access. Can you share a bit more about what you're trying to do?
Jakeyjuju
JakeyjujuOPā€¢8mo ago
Thanks for the help! Iā€™m trying to get some values written to a text file (or json) that could then be downloaded
Michal Srb
Michal Srbā€¢8mo ago
Storing Generated Files | Convex Developer Hub
Files can be uploaded to Convex from a client and stored directly, see
Jakeyjuju
JakeyjujuOPā€¢8mo ago
Thanks šŸ‘

Did you find this page helpful?