Sveltekit Failed to resolve import "cloudflare:sockets"
I was trying to use drizzle orm in a sveltekit project with postgres run in a docker container, but i'm having the following error
4 Replies
The project is only a svelkite project template with the following changes
couldnt figure up what was happening, I event add the cloudflare adaptor to the sveltekit.config.ts
its because of the "pg" package, imo i would just use postgres-js (https://www.npmjs.com/package/postgres) and not worry about that
npm
postgres
Fastest full featured PostgreSQL client for Node.js. Latest version: 3.3.5, last published: 6 days ago. Start using postgres in your project by running
npm i postgres
. There are 112 other projects in the npm registry using postgres.if you want to look into actually fixing your problem and still use pg, its because "pg" dynamically imports "pg-cloudflare", which itself dynamically imports "cloudflare:sockets", so youre trying to bundle these packages and gives you that error when you can't find them, even if they're not needed.
maybe this fixes it in your vite config, altho i wouldn't bother and would just move to postgres-js
I will try that thanks
@Maston lool, i'm so stupid, i was putting the load function in the server/cliennt instead of the
page.server.ts
xD