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

Nuxt reads a different env file if value is not found in the configured env file #360

Open
noook opened this issue Mar 13, 2024 · 1 comment · May be fixed by #381
Open

Nuxt reads a different env file if value is not found in the configured env file #360

noook opened this issue Mar 13, 2024 · 1 comment · May be fixed by #381

Comments

@noook
Copy link

noook commented Mar 13, 2024

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

  1. Configure .env and .env.local. In this example, .env refers to the template, .env.local refer to the actual values
  2. Keep the template env property empty
  3. Do not define it in .env.local (let nuxt.config.ts use the default value of runtime config)
  4. Run nuxt with nuxt dev --dotenv .env.local
  5. 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

Copy link

stackblitz bot commented Mar 13, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@danielroe danielroe transferred this issue from nuxt/nuxt Mar 14, 2024
@DamianGlowala DamianGlowala linked a pull request Mar 29, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant