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
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?
Thanks for the help! Iām trying to get some values written to a text file (or json) that could then be downloaded
You want to use File Storage:
https://docs.convex.dev/file-storage/store-files
Storing Generated Files | Convex Developer Hub
Files can be uploaded to Convex from a client and stored directly, see
Thanks š