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

Errors in Nuxt example #59

Open
lttr opened this issue May 10, 2023 · 5 comments
Open

Errors in Nuxt example #59

lttr opened this issue May 10, 2023 · 5 comments
Labels
bug Something isn't working PRs Accepted Feel free to pick this up and make a PR

Comments

@lttr
Copy link

lttr commented May 10, 2023

I'm trying to make this library work for Nuxt 3 application, but encountering errors:

Reproduction 1 (process.env not defined)

  1. Clone this repository
  2. cd examples/nuxt
  3. pnpm install
  4. pnpm run build
  5. pnpm run preview
  6. Open browser at localhost:3000
  7. There is an error in the console: Uncaught ReferenceError: process is not defined

The process variable is used here: https://github.com/t3-oss/t3-env/blob/b68140ae970c2626d56ed85b10be24dc909f8cab/packages/nuxt/index.ts#L22C66

Reproduction 2 (Invalid environment variables with an empty error object)

  1. Clone this repository
  2. cd examples/nuxt
  3. pnpm install
  4. pnpm run dev
  5. Open browser at localhost:3000
  6. There is an error in the console: ❌ Invalid environment variables: Object { }

The error originates from here:

((error: ZodError) => {

@intagaming
Copy link

intagaming commented May 10, 2023

1st problem about process: Might be because the code is accessing process on the client, which is in turn because the code (the t3-env Nuxt package) forgot to treat the server and the client differently. I know it is Nuxt but I just posted an issue describing how I approach Astro SSR, which is of course treating server and client code differently, at #60.

2nd problem about empty object: I think Nuxt is replacing process.env with undefined in development mode, which causes Zod to spit error in formErrors, not fieldErrors <- which is an empty object (my wild guess, but probably right).

Overall it comes down to the problem of accessing process.env on client-side. I'm in Next.js land, not Nuxt, so don't know how Nuxt names things, but that's the start.

@juliusmarminge
Copy link
Member

@nexxeln is the nuxt guy here

@ThimoDEV
Copy link

+1 Encountered Reproduction 2 too

@reslear
Copy link

reslear commented Jul 28, 2023

browser show only:

Screenshot 2023-07-28 at 15 03 34

@juliusmarminge juliusmarminge added bug Something isn't working PRs Accepted Feel free to pick this up and make a PR labels Aug 16, 2023
@reslear
Copy link

reslear commented Oct 17, 2023

so it turns out the nuxt version is not working, also I seem to have done something that would work but when using doppler run - nuxi dev HMR does not work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PRs Accepted Feel free to pick this up and make a PR
Projects
None yet
Development

No branches or pull requests

5 participants