electric-sql / electric-sql/pglite

Running pglite in the browser: `Error: createRequire is not a function`

Open
#322 12 comments 0 reactions 0 assignees View on GitHub
bundlers-nextjs/emsdk
Dominant language
TypeScript
Stars
16k
Forks
442
Avg merge
20h 19m
Merged PRs (30d)
7

Description

Following the install guide here: https://pglite.dev/docs/#install-and-start-in-the-browser

I span up a new Next.js app, installed pglite, then attempted to query the version. However when pulling in pglite, I get the error: `Error: createRequire is not a function`

Any ideas? works fine from Node & bun environments, but I cannot get it to work purely client side in the browser.

I've pushed an [example repo here](https://github.com/AdrianLThomas/nextjs-pglite):
- [Pulled in the package](https://github.com/AdrianLThomas/nextjs-pglite/blob/main/package.json#L12)
- [Tried to use it](https://github.com/AdrianLThomas/nextjs-pglite/blob/main/src/app/page.tsx#L3-L14)

Many thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.