-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
process.env.NODE_ENV is undefined #14547
Comments
Hey @asherccohen! Can you provide either more thorough repro steps or a reproduction which we can clone? As is, we don't really know how you generated the app, what kind of bundler or anything like that which is in use so it would be hard to diagnose any issues effectively. |
hi @AgentEnder , sorry for the lack of info and thanks for the quick answer. Hard to give proper steps, I had the monorepo since a long time and noticed the issue while upgrading to 15.5.2. Currently it's happening on a react app, but I'll check if it happens in libs too. It was created with nx g @nrwl/react:app my-new-app And here's the project.json:
Is there something else I could provide? |
I apologize for being demanding, is there any news on this issue? All my projects are blocked and I haven't found a valid workaround. Is there another way to read when apps are running in development or production? |
One way to proceed could be to downgrade NX to something below 15.5.0. I'm on 15.4.2 and |
Thanks but I can't do that at the moment. I've also noticed that NX_BASE is ignored when running CLI commands, could it be related? |
Running into the same issue. It's pretty easy to recreate. Create any new repo with below options I believe it was introduced in |
It's still an issue on 15.6. I've been debugging this a bit and searched for all the places where process.env.NODE_ENV is used. nx/src/executors/run-commands/run-commands.impl.ts nx/src/tasks-runner/forked-process-task-runner.ts // particularly here "dotenv.parse(envContents)" is not able to read NODE_ENV webpack/src/utils/with-web.ts I can force NODE_ENV manually in .env or create a run-command to conditionally serve:development/serve:production
Fun fact is that the "build" command instead is able to read process.env.NODE_ENV without an issue. Therefore the problem might be with the serve task-runner. So I'm unblocked, hopefully this is useful to get a proper fix. |
Same issue for me, happend with my latest upgrade from 15.4.5 to 15.6.3 |
Just checked, and it was indeed introduced in |
Any ideas on how can I set |
@AgentEnder any update on this? Fairly easy to reproduce and check through the changes introduced in 15.4.6. Happy to help with more info if needed and would appreciate keeping us posted with any updates 🙏🏼 |
Just chiming in to mention we're experiencing the same issue described above. |
I am experiencing the same issue! 😡 for now, i am running the app like this:
hope them solve this issue quickly! |
This should be fixed with the latest version. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
nx run my-ui:serve:development
logging process.env.NODE_ENV returns undefined
Expected Behavior
nx run my-ui:serve:development
logging process.env.NODE_ENV returns "development"
Github Repo
No response
Steps to Reproduce
nx run my-ui:serve:development
Nx Report
Failure Logs
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: