Mikitz
Mikitz
TTCTheo's Typesafe Cult
Created by Mikitz on 6/2/2024 in #questions
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, });
4 replies
TTCTheo's Typesafe Cult
Created by Mikitz on 1/27/2024 in #questions
create-t3-app help : something weird with .env
I followed along with the T3 Stack Tutorial - FROM 0 TO PROD FOR $0 video. I have watched these steps in the video 4 times now to make sure I've followed them correctly. My .env is set up. The DATABASE_URL is added into Vercel as an Environment Variable. I changed schema.prisma. My .env looks like the below. It runs with npm run dev.
PLANETSCALE_PRISMA_UN=blahblahblfklsdfklsdf
PLANETSCALE_PRISMA_PW=pscale_pw_asdfasdfasdfasdfasdfasdf
DATABASE_URL=mysql://asdfasdfasdfasdfasdfasfasdf:pscale_pw_asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf@aws.connect.psdb.cloud/sdfsfsdfdfs?sslaccept=strict
PLANETSCALE_PRISMA_UN=blahblahblfklsdfklsdf
PLANETSCALE_PRISMA_PW=pscale_pw_asdfasdfasdfasdfasdfasdf
DATABASE_URL=mysql://asdfasdfasdfasdfasdfasfasdf:pscale_pw_asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf@aws.connect.psdb.cloud/sdfsfsdfdfs?sslaccept=strict
Vercel error:
./src/server/db.ts:18:5
Type error: Type 'PrismaPlanetScale' is not assignable to type 'never'.
16 | log:
17 | env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
> 18 | adapter: new PrismaPlanetScale(client),
| ^
19 | });
20 |
21 | if (env.NODE_ENV !== "production") globalForPrisma.prisma = db;
Error: Command "npm run build" exited with 1
./src/server/db.ts:18:5
Type error: Type 'PrismaPlanetScale' is not assignable to type 'never'.
16 | log:
17 | env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
> 18 | adapter: new PrismaPlanetScale(client),
| ^
19 | });
20 |
21 | if (env.NODE_ENV !== "production") globalForPrisma.prisma = db;
Error: Command "npm run build" exited with 1
5 replies