terribleplan
terribleplan
CDCloudflare Developers
Created by terribleplan on 3/2/2024 in #workers-help
unable to deploy sveltekit when using postgres
I've been trying to deploy sveltekit using postgres, but am unable to get it to work with compatibility_flags = [ "nodejs_compat" ] or node_compat = true... I've made minimal repos showing it working with the default esbuild process wrangler does, while failing with sveltekid (which uses vite). Is anyone doing this something similar successfully? Any hints on how to tweak my vite.config.js to get it to work? Failing (sveltekit): https://terrible.software/terribleplan/svelte-kit-pg-cloudflare Working (no framework at all): https://terrible.software/terribleplan/raw-pg-cloudflare If you want to deploy the examples yourself make sure you update the wrangler.toml with a valid hyperdrive id. The errors I am getting from vite are of this variety (depending on how exactly I tweak my wrangler config to use compatibility_flags = [ "nodejs_compat" ] or node_compat = true):
✘ [ERROR] Could not resolve "node:path" (originally "path")

node_modules/pgpass/lib/index.js:3:19:
3 │ var path = require('path')
╵ ~~~~~~

The path "path" was remapped to "node:path" using the alias feature, which then couldn't be resolved. Keep in mind that import path aliases are resolved in the current working directory.

Cannot use "node:path" when deploying to Cloudflare.


✘ [ERROR] Could not resolve "fs"

node_modules/pgpass/lib/index.js:4:17:
4 │ , fs = require('fs')
╵ ~~~~

Cannot use "fs" when deploying to Cloudflare.
✘ [ERROR] Could not resolve "node:path" (originally "path")

node_modules/pgpass/lib/index.js:3:19:
3 │ var path = require('path')
╵ ~~~~~~

The path "path" was remapped to "node:path" using the alias feature, which then couldn't be resolved. Keep in mind that import path aliases are resolved in the current working directory.

Cannot use "node:path" when deploying to Cloudflare.


✘ [ERROR] Could not resolve "fs"

node_modules/pgpass/lib/index.js:4:17:
4 │ , fs = require('fs')
╵ ~~~~

Cannot use "fs" when deploying to Cloudflare.
13 replies