Open
Description
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
- Clone this repository
- Run
pnpm install
Regular dev mode (works)
- Run
pnpx nx run backend:dev
- Check the console output,
nuxt dev
is run - Check the app in the browser, it shows
.env / default
as expected
Staging dev mode (doesn't work)
- Run
pnpx nx run backend:dev:staging
- Check the console output,
nuxi dev --dotenv .env.staging
is run - Check the app in the browser, it shows
.env / default
instead of.env.staging / staging
Manually running the staging command (works)
- Run
cd apps/backend
- Run
nuxi dev --dotenv .env.staging
- Check the app in the browser, it shows
.env.staging / staging
as expected
Additional context
No response
Logs
No response