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

Using nuxi --dotenv .env.staging not working as expected inside NX monorepo #444

Open
L422Y opened this issue Jun 29, 2024 · 0 comments
Open

Comments

@L422Y
Copy link
Contributor

L422Y commented Jun 29, 2024

Environment

root nx project

  • Operating System: Darwin
  • Node Version: v20.12.2
  • Nuxt Version: -
  • CLI Version: 3.12.0
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

apps/backend project

  • Operating System: Darwin
  • Node Version: v20.12.2
  • Nuxt Version: 3.12.2
  • CLI Version: 3.12.0
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, runtimeConfig
  • Runtime Modules: -
  • Build Modules: -

Reproduction

stackblitz.com/github/L422Y/nuxt-nx-bug
github.com/L422Y/nuxt-nx-bug

Describe the bug

We have a Nuxt app that is part of a Nx workspace. There is a .env and a .env.staging file in the root of the apps/backend Nuxt app. The .env.staging file should be used when running the dev:staging task.

The problem is that when the dev:staging task is run, the .env file is used instead of the .env.staging file, even though the appropriate command is run in the correct directory (or it appears to be).

When the nuxi dev --dotenv .env.staging command is run manually in the apps/backend directory, it works as expected.

Not sure if this is a bug in Nx, Nuxt, or something else.

Steps to reproduce

  1. Clone this repository
  2. Run pnpm install

Regular dev mode (works)

  1. Run pnpx nx run backend:dev
  2. Check the console output, nuxt dev is run
  3. Check the app in the browser, it shows .env / default as expected

Staging dev mode (doesn't work)

  1. Run pnpx nx run backend:dev:staging
  2. Check the console output, nuxi dev --dotenv .env.staging is run
  3. Check the app in the browser, it shows .env / default instead of .env.staging / staging

Manually running the staging command (works)

  1. Run cd apps/backend
  2. Run nuxi dev --dotenv .env.staging
  3. Check the app in the browser, it shows .env.staging / staging as expected

Additional context

No response

Logs

No response

@L422Y L422Y changed the title Using nuxi --dotenv .env.staging not working as expected inside NX monorepo [nuxt] Using nuxi --dotenv .env.staging not working as expected inside NX monorepo Jun 29, 2024
@L422Y L422Y changed the title [nuxt] Using nuxi --dotenv .env.staging not working as expected inside NX monorepo Using nuxi --dotenv .env.staging not working as expected inside NX monorepo Jun 29, 2024
@danielroe danielroe transferred this issue from nuxt/nuxt Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants