sveltekit and node errors on build
Trying to use Sveltekit, with Supabase and Drizzle ORM preferably.
- I've put
nodejs_compat
in the compatibility flags in both preview and production
- Node version is 18 (set via environment variable)
- I'm using build engine 1
- Using Sveltekit.
- my postgres client instantiation is in $lib/server/
which I'm told makes it definitely server only
- Using the cloudflare sveltekit adapter.
Cant seem to find anything online why it'd be throwing this.3 Replies
Also says
The package "node:buffer" 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.
but I have no clue where I would put this platform:'node'
I've had no problems with builds until I added postgres
Actually, so I'm using Drizzle ORM and their instructions for Cloudflare Workers say to use:
instead.
I get these errors with pg
...
node-postgres
requires polyfills on Workers, usually provided by the node_compat
Wrangler flags.
The reason that you're getting errors with node:
modules, despite having nodejs_compat
enabled, is probably because the Svelte adapter doesn't have node:
marked as external in their esbuild config (which Wrangler does).
node_compat
isn't available on Pages, meaning node-postgres
isn't really an option unless you can provide the polyfills into the build process yourself.Thank you. Thats quite frustrating. Digging through github issues trying to find options