You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is this package intended to work in the browser? I'm currently trying to initialize an IndexedDB-backed PGlite database on the client-side, but create-migrator seems to rely on packages which expect to be run in node.
My code:
import{createMigrator,KyselyPGlite}from"kysely-pglite";import{Dialect,Kysely}from"kysely";import{openDB}from"idb";importtype{DB}from"./schema";constDB_NAME="my-db";constDB_VERSION=1;asyncfunctioninitializeDatabase(){// Open or create the IndexedDB databaseawaitopenDB(DB_NAME,DB_VERSION);// Create a KyselyPGlite instance backed by IndexedDBconstdialect=newKyselyPGlite(`idb://${DB_NAME}`);// Create the Kysely instanceconstdb=newKysely<DB>({dialect: dialectasunknownasDialect,log(event){console.log(event.query.sql);console.log(event.query.parameters);},});// Create the migratorconstmigrator=createMigrator(db,"src/db/migrations");// Run migrationsconsole.log("Migrating to latest");const{ error, results }=awaitmigrator.migrateToLatest();if(error){console.error("Migration failed:",error);}elseif(results){console.log("Migration results:",results);}returndb;}// Export a promise that resolves to the db instanceexportconstdbPromise=initializeDatabase();
Next is unable to build this because the migrator has packages in it's dependency tree which expect to have fs present.
Module not found: Can't resolve 'fs'Did you mean './fs'?Requests that should resolve in the current directory need to start with './'.Requests that start with a name are treated as module requests and resolve within module directories (node_modules).If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.https://nextjs.org/docs/messages/module-not-foundImport trace for requested module:./node_modules/@nodelib/fs.scandir/out/settings.js./node_modules/@nodelib/fs.scandir/out/index.js./node_modules/@nodelib/fs.walk/out/settings.js./node_modules/@nodelib/fs.walk/out/index.js./node_modules/fast-glob/out/readers/async.js./node_modules/fast-glob/out/providers/async.js./node_modules/fast-glob/out/index.js./node_modules/globby/index.js./node_modules/kysely-pglite/dist/utils/create-migrator.js./node_modules/kysely-pglite/dist/index.js./src/db/index.ts./src/components/HomePage.tsx./src/app/page.tsx ⨯ ./node_modules/@nodelib/fs.scandir/out/adapters/fs.js:4:1
The text was updated successfully, but these errors were encountered:
Is this package intended to work in the browser? I'm currently trying to initialize an IndexedDB-backed PGlite database on the client-side, but
create-migrator
seems to rely on packages which expect to be run in node.My code:
Next is unable to build this because the migrator has packages in it's dependency tree which expect to have
fs
present.The text was updated successfully, but these errors were encountered: