electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.45k stars 204 forks source link

'@electric-sql/pglite' does not provide an export named 'NodeFS' #413

Closed GeorgiosP closed 2 days ago

GeorgiosP commented 2 weeks ago

Looking at the docs for node / bun its listing NodeFS for retaining content in the file system for some persistence any assistance would be greatly appreciated!

https://pglite.dev/docs/filesystems#node-fs

using version 0.2.12

cannot use NodeFS since its saying it does not exist 😢

pmp-p commented 2 weeks ago

postgres.js node build is in interim archive and does support FS ( i use it with bun and pglite-server/pg-gateway everyday), if it says NodeFS is missing then the postgres.js picked up is probably the web version.

GeorgiosP commented 2 weeks ago

Got it! is it also included in the PGLite since I'm using that here?

I'm running on my server not in client but the only way I've managed to get it to play nice is using memory:// during PGLite setup

  const client = await PGlite.create({ dataDir: "memory://" });
  const db = drizzle(client);
pmp-p commented 2 weeks ago

if you want to use Node raw fs you can unpack "/tmp/pglite" on the drive first so it can create "base" in it ( as it will mount it on /tmp/pglite in node vfs ) nb: base must not exist prior to initdb / first pglite setup ! eg

const db = new PGlite("/tmp/pglite/base", {
    "username" : "postgres",
    "debug" : true,
    extensions: {
        "vector" : new URL("./node_modules/@electric-sql/pglite/dist/vector.tar.gz", import.meta.url),
  }
});
GeorgiosP commented 2 weeks ago

Sweet! I'll give that a shot 🙏🏼

GeorgiosP commented 2 days ago

Closing this out for now appreciate the support 🫡 unpack works well but its not super sustainable