Vercel: Error: Invalid environment variables

I'm at a loss, y'all. Please help. My .env has each kv pair like KEY="variable". They have all been added to Vercel, too.
the error is below
⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error Build error occurred Error: Invalid environment variables at onValidationError (file:///vercel/path0/node_modules/@t3-oss/env-core/dist/index.js:29:15) at createEnv (file:///vercel/path0/node_modules/@t3-oss/env-core/dist/index.js:35:16) at createEnv (file:///vercel/path0/node_modules/@t3-oss/env-nextjs/dist/index.js:12:12) at file:///vercel/path0/src/env.js:4:20 at ModuleJob.run (node:internal/modules/esm/module_job:195:25) at async ModuleLoader.import (node:internal/modules/esm/loader:336:24) at async file:///vercel/path0/next.config.js:5:1 Error: Command "npm run build" exited with 1
env.js is below
import { createEnv } from "@t3-oss/env-nextjs"; import { z } from "zod"; export const env = createEnv({ / * Specify your server-side environment variables schema here. This way you can ensure the app * isn't built with invalid env vars. */ server: { DATABASE_URL: z.string().url(), NODE_ENV: z .enum(["development", "test", "production"]) .default("development"), CLERK_SECRET_KEY: z.string(), TURSO_DATABASE_URL: z.string().url(), TURSO_AUTH_TOKEN: z.string(), }, / * Specify your client-side environment variables schema here. This way you can ensure the app * isn't built with invalid env vars. To expose them to the client, prefix them with * NEXT_PUBLIC_. */ client: { NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: z.string(), NEXT_PUBLIC_CLERK_SIGN_IN_URL: z.string(), NEXT_PUBLIC_CLERK_SIGN_UP_URL: z.string(), NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL: z.string(), NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL: z.string(), }, / * You can't destruct process.env as a regular object in the Next.js edge runtimes (e.g. * middlewares) or client-side so we need to destruct manually. */ runtimeEnv: { DATABASE_URL: process.env.DATABASE_URL, NODE_ENV: process.env.NODE_ENV, NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY: process.env.CLERK_SECRET_KEY, NEXT_PUBLIC_CLERK_SIGN_IN_URL: process.env.NEXT_PUBLIC_CLERK_SIGN_IN_URL, NEXT_PUBLIC_CLERK_SIGN_UP_URL: process.env.NEXT_PUBLIC_CLERK_SIGN_UP_URL, NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL: process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL, NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL: process.env.NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL, TURSO_DATABASE_URL: process.env.TURSO_DATABASE_URL, TURSO_AUTH_TOKEN: process.env.TURSO_AUTH_TOKEN, }, / * Run build or dev with SKIP_ENV_VALIDATION to skip env validation. This is especially * useful for Docker builds. */ skipValidation: !!process.env.SKIP_ENV_VALIDATION, /** * Makes it so that empty strings are treated as undefined. SOME_VAR: z.string() and * SOME_VAR='' will throw an error. */ emptyStringAsUndefined: true, });
Solution:
The solution was to import from the .env file instead of copy-pasting from it.
Jump to solution
1 Reply
Solution
Mikitz
Mikitz6mo ago
The solution was to import from the .env file instead of copy-pasting from it.
Want results from more Discord servers?
Add your server