Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error saying 'clientPrefix' property does not exist #278

Open
avibathula opened this issue Oct 28, 2024 · 0 comments
Open

Error saying 'clientPrefix' property does not exist #278

avibathula opened this issue Oct 28, 2024 · 0 comments

Comments

@avibathula
Copy link

avibathula commented Oct 28, 2024

In a TS based nextJS project with strict typing enforced, I installed packages using

npm install zod @t3-oss/env-nextjs

and when I use 'clientPrefix' property to validate that all client side properties have the prefix of 'NEXT_PUBLIC_'

import { z } from 'zod';
import { createEnv } from '@t3-oss/env-nextjs';

export const env = createEnv({
  clientPrefix: 'NEXT_PUBLIC_',
  server: {
    LOGTAIL_TOKEN: z.string().nonempty().optional(), // optional if not always needed
    NODE_ENV: z.enum(['development', 'test', 'production']),
  },
  client: {
    NEXT_PUBLIC_APP_URL: z.string().url().optional(),
  },
  runtimeEnv: {
    LOGTAIL_TOKEN: process.env.LOGTAIL_TOKEN,
    NODE_ENV: process.env.NODE_ENV,
    NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
  },
});

I even tried

npm cache clean --force
rm -rf node_modules
npm install

but the error remains.

Object literal may only specify known properties, and 'clientPrefix' does not exist in type 'Omit<StrictOptions<"NEXT_PUBLIC_", { LOG_ENABLED: ZodOptional<ZodString>; LOG_LEVEL: ZodOptional<ZodString>; LOGTAIL_SOURCE_TOKEN: ZodOptional<ZodString>; }, { ...; }, { ...; }, []> & ServerClientOptions<...>, "clientPrefix" | ... 1 more ... | "runtimeEnv"> & { ...; }'.

and everything runs fine if I remove 'clientPrefix' property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant