Drizzle not pulling in environment variables

So originally my app was fine with the env variables originally but now it is not working. I am not sure what is going on. I have tried to use the dotenv package but that did not work. my drizzle config
import { type Config } from 'drizzle-kit';
import { env } from './env.mjs';

import * as dotenv from "dotenv";
dotenv.config();

export default {
schema: './src/db/schemas/',
out: './src/db/migrations',
driver: 'mysql2',
dbCredentials: {
connectionString: env.DATABASE_URL,
},
} satisfies Config;
import { type Config } from 'drizzle-kit';
import { env } from './env.mjs';

import * as dotenv from "dotenv";
dotenv.config();

export default {
schema: './src/db/schemas/',
out: './src/db/migrations',
driver: 'mysql2',
dbCredentials: {
connectionString: env.DATABASE_URL,
},
} satisfies Config;
the error i am getting
pnpm db:push

> [email protected] db:push G:\GitHub\Meally\apps\meally
> drizzle-kit push:mysql --config=drizzle.config.ts

drizzle-kit: v0.19.5
drizzle-orm: v0.27.2

Reading config file 'G:\GitHub\Meally\apps\meally\drizzle.config.ts'
Invalid environment variables: {
DATABASE_URL: [ 'Required' ],
DATABASE_HOST: [ 'Required' ],
DATABASE_USERNAME: [ 'Required' ],
DATABASE_PASSWORD: [ 'Required' ],
NODE_ENV: [ 'Required' ],
NEXTAUTH_URL: [ 'Required' ],
NEXTAUTH_SECRET: [ 'Required' ],
GITHUB_CLIENT_ID: [ 'Required' ],
GITHUB_CLIENT_SECRET: [ 'Required' ],
GOOGLE_CLIENT_ID: [ 'Required' ],
GOOGLE_CLIENT_SECRET: [ 'Required' ],
FACEBOOK_APP_ID: [ 'Required' ],
FACEBOOK_CLIENT_SECRET: [ 'Required' ],
TWITTER_API_KEY: [ 'Required' ],
TWITTER_API_SECRET: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_API_KEY: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_PROJECT_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_APP_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: [ 'Required' ],
NEXT_PUBLIC_APP_URL: [ 'Required' ]
}
G:\GitHub\Meally\node_modules\.pnpm\@[email protected][email protected][email protected]\node_modules\@t3-oss\core\index.ts:205
!prop.startsWith(opts.clientPrefix) &&
pnpm db:push

> [email protected] db:push G:\GitHub\Meally\apps\meally
> drizzle-kit push:mysql --config=drizzle.config.ts

drizzle-kit: v0.19.5
drizzle-orm: v0.27.2

Reading config file 'G:\GitHub\Meally\apps\meally\drizzle.config.ts'
Invalid environment variables: {
DATABASE_URL: [ 'Required' ],
DATABASE_HOST: [ 'Required' ],
DATABASE_USERNAME: [ 'Required' ],
DATABASE_PASSWORD: [ 'Required' ],
NODE_ENV: [ 'Required' ],
NEXTAUTH_URL: [ 'Required' ],
NEXTAUTH_SECRET: [ 'Required' ],
GITHUB_CLIENT_ID: [ 'Required' ],
GITHUB_CLIENT_SECRET: [ 'Required' ],
GOOGLE_CLIENT_ID: [ 'Required' ],
GOOGLE_CLIENT_SECRET: [ 'Required' ],
FACEBOOK_APP_ID: [ 'Required' ],
FACEBOOK_CLIENT_SECRET: [ 'Required' ],
TWITTER_API_KEY: [ 'Required' ],
TWITTER_API_SECRET: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_API_KEY: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_PROJECT_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_APP_ID: [ 'Required' ],
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: [ 'Required' ],
NEXT_PUBLIC_APP_URL: [ 'Required' ]
}
G:\GitHub\Meally\node_modules\.pnpm\@[email protected][email protected][email protected]\node_modules\@t3-oss\core\index.ts:205
!prop.startsWith(opts.clientPrefix) &&
Solution:
^- this. also, do you get the same error while building your app or just pushing? P.S. if you want to use dotenv as a workaround, you have to import variables using process.env.YOU_ENV_VAR as it won't affect the t3env env object...
Jump to solution
5 Replies
Lopen
Lopen17mo ago
Are you using the t3 stack?
Solution
Sturlen
Sturlen17mo ago
^- this. also, do you get the same error while building your app or just pushing? P.S. if you want to use dotenv as a workaround, you have to import variables using process.env.YOU_ENV_VAR as it won't affect the t3env env object
baddra
baddra17mo ago
baddra
baddra17mo ago
If you are using planetscale you need these variables
Jacob
JacobOP17mo ago
Right ok thankyou, I’m not using the t3 stack just the environment variable package but I’ll try this
Want results from more Discord servers?
Add your server