nx: WARNING in DefinePlugin Conflicting values for 'process.env.NODE_ENV'
- Have installed the latest NX 13.2.2.
- Created empty react project.
- Created a library with
--publishableflag. - Created an empty component inside the library.
When executing command yarn nx run my-project:build got a warning message:
WARNING in DefinePlugin Conflicting values for ‘process.env.NODE_ENV’
I didn’t change any default nx settings during nx installation or when creating the project.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 26
- Comments: 69 (11 by maintainers)
Commits related to this issue
- fix(react): this should fixed `serve` command always build development built close #7924 — committed to kamontat/nx by kamontat 2 years ago
- fix(react): fix conflicting NODE_ENV values between an application and webpack Plugins (DefinePlugin) ISSUES CLOSED: #7924 — committed to ndcunningham/nx by deleted user 2 years ago
- fix(react): fix conflicting NODE_ENV values between an application and webpack Plugins (DefinePlugin) (#9460) ISSUES CLOSED: #7924 Co-authored-by: Nicholas Cunningham <ndcunningham> — committed to nrwl/nx by ndcunningham 2 years ago
- fix(react): fix conflicting NODE_ENV values between an application and webpack Plugins (DefinePlugin) (#9460) ISSUES CLOSED: #7924 Co-authored-by: Nicholas Cunningham <ndcunningham> — committed to nrwl/nx by ndcunningham 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options Closes #7924 — committed to jaysoo/nx by jaysoo 2 years ago
- fix(react): pass configuration from context when reading build target options (#9656) Closes #7924 — committed to nrwl/nx by jaysoo 2 years ago
- fix(react): fix conflicting NODE_ENV values between an application and webpack Plugins (DefinePlugin) (#9460) ISSUES CLOSED: #7924 Co-authored-by: Nicholas Cunningham <ndcunningham> — committed to sidmonta/nx by ndcunningham 2 years ago
- fix(react): pass configuration from context when reading build target options (#9656) Closes #7924 — committed to sidmonta/nx by jaysoo 2 years ago
- Fix WARNING in DefinePlugin Conflicting values for process.env.NODE_ENV Followed project config in https://github.com/nrwl/nx/issues/7924#issuecomment-1072591736 — committed to caribou-crew/mezzo by sdg9 2 years ago
I updated to
13.9.5and still get this warningWARNING in DefinePlugin Conflicting values for 'process.env.NODE_ENV'Anything else I can do to resolve this?
@jaysoo I think this issue needs to be reopened since #9460 did not fix the issue
Still present in 13.4.3
Update: I found what caused the regression. It was due to another fix we did here #8932.
The PR to fix this has been opened, just getting a round of review and we should include it in 13.10.
I encountered this issue as well, in a project where the
NODE_ENVneeds to be “testing” for local development, but was always getting set to “development.”Turns out Webpack’s
modeparameter setsprocess.env.NODE_ENVviaDefinePlugin[0]. So, if you use bothmode: 'development'and an instance ofDefinePlugin,process.env.NODE_ENVcan get set with conflicting values…Another config option I found helpful was setting
stats.errorDetails: true[1]. This causes DefinePlugin to print the old and new values to stdout, which was helpful in debugging.[0] https://webpack.js.org/configuration/mode/ [1] https://webpack.js.org/configuration/stats/#statserrordetails
FYI The error still occurs on out-of-the-box untouched code:
Tested today.
this bug is still present in v13.8.4
Add
NODE_ENV=productionto any.envfiles such as.env.localsolved problem without prefix to scripts.Done a little more digging and this still happens out of the box using newest versions of
@nrwl/*@latest(13.8.7at time of writing) packages. By this I mean I can create a brand new project and start it and this issue/warning message occurs.So I suspect this is a bug?
this bug is still present in v13.8.5. Is there any workaround for this for now?
Still present in 13.83
@jaysoo Is it possibile reopen the issue after the @prewk clean test?
Hi @msageryd @nemonemi, below is my
project.jsonfile. In this file I just add line 38 and update line 44 as suggestion from @cbl980226, no need to defineNODE_ENVin.envanymore and it’s work fine. Hope this help!Spent a good chunk of the weekend using
git bisectalong with the NX tooling (yarn e2e-start-local-registryandyarn e2e-build-package-publishtasks in this repo) to jump between commits between v13.8.3 and v13.8.4 releases. Managed to narrow this issue down to the change made in #8932 .Not sure what those changes were intended to do or if this behaviour is in fact intended functionality (as I’m new to NX). But:
I hope this helps someone more familiar with NX fix this issue. Thanks all!
EDIT: Looking closer at the changes in that PR -
targetConfiguration.defaultConfigurationisproductionwhen running the local development server.I’m also having this issue as of upgrading to 13.8.5
And not only am I getting this warning, I also have my react app running with the production environment. My website was contacting the prod api URL and it took me a while to understand why.
@FloNeu @prewk as far as Storybook is concerned:
This is an issue that appears in the Storybook side. You can check out this reproduction, which is just a pure Angular app (no Nx) with Storybook. The same warning appears. Check out the log here. On Nx, we are using the Storybook builders directly (
@storybook/angular:start-storybook). There’s no “middle-person” between your app and Storybook in that case. So all logs are on the Storybook side. You can open an issue on the Storybook repo about that warning!Thank you all so much!! 😄
@mandarini Repro is out of the box. Yes it’s just a warning, I would put it way down on the priority list 😁
I not sure how you guy test THE FIX that you made, I saw that you already have couple of fix already that it NOT FIX ANYTHING. Have you ever test your fix?
Although, I haven’t tested on version 13.10 just yet.
To me, just removing the
defaultConfigurationsetting altogether fixed this. Not sure about all the consequences and not sure if this is correct solution, but seems OK so far. The production build is run with explicit--configuration productionparameter.Would love to provide the reproduction - but time is tight right now. But it was just an out-of-the box angular-workspace and setting up storybook for the generated angular-project at nx@latest.
Still getting this on
13.10.1@msageryd I use your
project.jsonfile, then modified at below. After that both commandnx serve portal&nx build portalran successfully.I guess the warning was introduced by https://github.com/nrwl/nx/pull/7727