Nuxt reads a different env file if value is not found in the configured env file
noook opened this issue · 1 comments
noook commented
Environment
- Operating System:
Darwin
- Node Version:
v21.6.2
- Nuxt Version:
3.10.3
- CLI Version:
3.10.1
- Nitro Version:
2.9.3
- Package Manager:
pnpm@8.15.4
- Builder:
-
- User Config:
devtools
,typescript
,colorMode
,modules
,runtimeConfig
,nitro
,tailwindcss
,supabase
,experimental
- Runtime Modules:
@nuxtjs/supabase@1.1.7
,@nuxt/ui@2.14.2-28504661.f4a48f6
,@nuxt/fonts@0.0.2
,@vueuse/nuxt@10.9.0
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-xxfchy
Describe the bug
- Configure
.env
and.env.local
. In this example,.env
refers to the template,.env.local
refer to the actual values - Keep the template env property empty
- Do not define it in
.env.local
(letnuxt.config.ts
use the default value of runtime config) - Run nuxt with
nuxt dev --dotenv .env.local
- Nuxt fallbacks on
.env
file's values if it doesn't find it in the configured env file.env.local
Additional context
I digged a bit and I can't tell whether the issue comes from @nuxt/cli
or @nuxt/kit
. I noticed sometimes the dotenv
property is not passed as a string but casted as a boolean, which makes dotenv
load the default env file (.env
) instead of the one configured
const opts = {
// ...
dotenv: !!ctx.args.dotenv,
// ...
}
Logs
No response
stackblitz commented
Start a new pull request in StackBlitz Codeflow.