Skip to content

nuxt cli --dotenv flag not honored #672

@joel-wenzel

Description

@joel-wenzel

Environment


  • Operating System: Windows_NT
  • Node Version: v16.17.0
  • Nuxt Version: 2.16.0-27720022.54e852f
  • Nitro Version: 1.0.0
  • Package Manager: npm@8.18.0
  • Builder: webpack
  • User Config: typescript, alias, bridge, nitro, ssr, render, target, imports, loading, head, css, srcDir, plugins, components, buildModules, i18n, modules, publicRuntimeConfig, axios, router, vuetify, build, ignore, serverHandlers, devServerHandlers, devServer
  • Runtime Modules: @nuxtjs/axios@5.13.6,
    @nuxtjs/i18n@7.3.0
  • Build Modules: (), @pinia/nuxt@0.4.6, @nuxtjs/svg@0.1.12, @nuxtjs/vuetify@1.12.3, @nuxt/bridge@3.0.0-27833237.ddd8ecc------------------------------

Reproduction

Not needed ( i dont think )

Describe the bug

nuxi commands always use the default .env file even if the --dotenv arg is specified

Additional context

I think the right spot for the fix is @nuxt/config-edge src/load.js loadNuxtConfig

With nuxi the incoming env config has the following pattern:

{
  cwd: 'C:/code/Tempest/flexdeploy',        
  fileName: 'production.env'
}

which is the spread here:

envConfig = {
    dotenv: ".env",
    env: process.env,
    expand: true,
    ...envConfig
  };

Just changing to dotenv: envConfig.fileName ?? ".env" does the trick

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions