This is a bug reproduction repository for Nuxt and Nx with pnpm workspaces.
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.
- Clone this repository
- Run
pnpm install
- 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
- 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
- Run
cd apps/backend
- Run
nuxi dev --dotenv .env.staging
- Check the app in the browser, it shows
.env.staging / staging
as expected