Errors in Nuxt example
I'm trying to make this library work for Nuxt 3 application, but encountering errors:
Reproduction 1 (process.env not defined)
- Clone this repository
- cd examples/nuxt
- pnpm install
- pnpm run build
- pnpm run preview
- Open browser at localhost:3000
- 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)
- Clone this repository
- cd examples/nuxt
- pnpm install
- pnpm run dev
- Open browser at localhost:3000
- There is an error in the console: ❌ Invalid environment variables: Object { }
The error originates from here: https://github.com/t3-oss/t3-env/blob/b68140ae970c2626d56ed85b10be24dc909f8cab/packages/core/index.ts#L123
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.
@nexxeln is the nuxt guy here
+1 Encountered Reproduction 2 too
browser show only:
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 :(