'process is not defined' in Sveltekit SPA
Hi, I have a monorepo (turborepo) and I have my drizzle instance as a package. In my schema I have
createInsertSchema
I want to use in my frontend to do form validation. The problem is I get the error process is not defined
because the code is ran from the client. In FF devtools I see it goes wrong at user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
(line 8 @ http://localhost:5173/node_modules/pg/lib/defaults.js). Why does it need pg
in the first place? I only import the createInsertSchema.
Here is the code:
/// Database package:
packages\database\index.ts
packages\database\database.ts
packages\database\schema.ts
//// My Sveltekit app
The code lives in a component e.g. myForm.svelte
Simply importing the create schema makes it pop the error. Any help is appreciated.1 Reply
Hmm.. I found https://discord.com/channels/1043890932593987624/1187446556782239816/1187448962005872660 which makes me believe this is not the best way to do this. I might just define the validation schemas in my frontend.