a16z-infra / ai-town

A MIT-licensed, deployable starter kit for building and customizing your own version of AI town - a virtual town where AI characters live, chat and socialize.
https://convex.dev/ai-town
MIT License
7.74k stars 718 forks source link

Unable to import FS #244

Closed Jake-Samuels closed 3 months ago

Jake-Samuels commented 5 months ago

I'm trying to import FS in order to write the outputs of each conversation to a JSON file, but importing the FS module returns the following error:

X [ERROR] Could not resolve "fs"

convex/messages.ts:5:20:
  5 │ import * as fs from "fs";
    ╵                     ~~~~

The package "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.

Any ideas how to fix this? I've tried adding FS directly to the node_modules directory but it isn't able to import it.

ianmacartney commented 5 months ago

This isn't running in a node server and it doesn't have access to the filesystem. The conversations are already being written to the database - you could write to another table in a different format, if you want it in a different format than it's already in? You can dump the database with just convex export and there will be a .jsonl file with the messages, but you'll have to connect them with their associated conversations. make sense?