React Vite env problem

I am trying react vite + drizzle. however, I don't know what's the issue here.
No description
No description
2 Replies
Mozzy
Mozzy2mo ago
Why not use process.env here?
Kuba
Kuba2mo ago
Take a look at https://discord.com/channels/1043890932593987624/1290460784912240721 I've gone through the similar debugging process there + given extra tip to consider in such setup But from quickly looking at it - import.meta.env is available only when running through vite - which doesn't happen when running drizzle-kit Use process.env instead and don't forget to load env vars:
import { defineConfig } from "drizzle-kit";
import { config } from "dotenv";
import { expand } from "dotenv-expand";

const env = config();
expand(env);

export default defineConfig({
schema: "./src/core/database/schema.ts",
out: "./database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
verbose: true,
strict: true,
});
import { defineConfig } from "drizzle-kit";
import { config } from "dotenv";
import { expand } from "dotenv-expand";

const env = config();
expand(env);

export default defineConfig({
schema: "./src/core/database/schema.ts",
out: "./database/migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL ?? "",
},
verbose: true,
strict: true,
});
Want results from more Discord servers?
Add your server