cli icon indicating copy to clipboard operation
cli copied to clipboard

nuxt preview does not respect the --dotenv option

Open martinszeltins opened this issue 1 year ago • 5 comments

Environment

Stackblitz

------------------------------
- Operating System: Linux
- Node Version:     v18.18.0
- Nuxt Version:     3.11.1
- CLI Version:      3.11.1
- Nitro Version:    2.9.5
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools, runtimeConfig
- Runtime Modules:  -
- Build Modules:    -
------------------------------

Reproduction

https://stackblitz.com/edit/nuxt-starter-qwahbu?file=package.json

Describe the bug

I have 2 environment files .env and .env.prod. According to the docs, I can pass the --dotenv flag to specify a different env file to load for nuxt preview command - https://nuxt.com/docs/api/commands/preview

But it does not seem to work.

I have tried multiple variants of this and it always loads the .env file and not my .env.prod file.

Here is what I tried (see reproduction):

+ "preview": "nuxt preview --dotenv .env.prod"
+ "preview": "nuxt preview --dotenv=.env.prod"
+ "preview": "nuxt preview --dotenv prod"

Nothing worked.

Additional context

No response

Logs

No response

martinszeltins avatar Mar 30 '24 09:03 martinszeltins

I have just experienced the same (with Nuxt 3.10.3 as well as 3.11.2).

Doc says it should work (https://nuxt.com/docs/api/commands/preview)

But my terminal even says it's just going to load .env

Xnapper-2024-04-23-18 34 45

I hope this helps possibly locate the issue.

chrisspiegl avatar Apr 23 '24 16:04 chrisspiegl

Been going mad experiencing the exact same issue. Nuxt 3.13.2.

dixhuit avatar Oct 02 '24 12:10 dixhuit