#Environment variable not being read for drizzle-kit push.

1 messages · Page 1 of 1 (latest)

minor token
#

I thought I'd give Drizzle a try instead of Prisma for a new use case, because it looks simpler. After following their guide, and creating this config, then running drizzle-kit push as per the guide, I get an invalid URL error because my env var isn't being read. I'm guessing this is because the Nextjs runtime isn't reading .env because this runs independenly of it. If I hard code the url here the push works fine. What can I do to somehow get the evn read?

import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';

require('dotenv').config();

export default defineConfig({
  out: './drizzle',
  schema: './src/drizzle/schema.ts',
  dialect: 'postgresql',
  dbCredentials: {
    url: process.env.DATABASE_URL || "",
  },
});

The require is merely the last of many attempts to get the variables read, none of which worked.

lime plumeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

bitter sky
minor token
bitter sky
#

Oh ok. Please mark solution:

lime plumeBOT