-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
NODE_ENV is undefined #16960
Comments
same problem. (macOS or Linux docker) |
same problem also |
Other executors set NODE_ENV, e.g. nx/packages/webpack/src/executors/webpack/webpack.impl.ts Lines 99 to 101 in 25328b3
but the node executor does not, as far as I can see: |
temp workaround // in your webpack.config.ts
// workaround for undefined NODE_ENV
const withFixedNodeEnv: () => NxWebpackPlugin =
() =>
(config, { context }) => {
if (config.mode && config.mode !== 'none') {
return config;
}
if (context.configurationName === 'production') {
config.mode = 'production';
} else {
config.mode = 'development';
}
return config;
};
export default composePlugins(withNx(), withFixedNodeEnv(), (config) => {
// Update the webpack config as needed here.
// e.g. config.plugins.push(new MyPlugin())
// For more information on webpack config and Nx see:
// https://nx.dev/packages/webpack/documents/webpack-config-setup
return config;
}); (which requires that you have a configuration named |
@ndcunningham Thank you for fixing this for esbuild! Sadly, this is also present for webpack too, so I don't think it's fully resolved yet. |
I'm not sure the fix that was merged has anything to do with |
A temporary workaround from @janeklb does not work in my case. I have managed to run it properly using
This way, serving the app with the I did some debugging and my closest bet is that this PR broke the previously working functionality: dc71229 I suppose executing a @jaysoo any idea on that one? |
… undefined closes: nrwl#16960
… undefined closes: nrwl#16960
… undefined closes: nrwl#16960
… undefined closes: nrwl#16960
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
Creating a new standalone Node application with NX 16.1.0 and console logging
process.env.NODE_ENV
gives back undefined,even though it was always defined in versions 15 anb below.
Using --prod during build also doesn't change anything.
Expected Behavior
process.env.NODE_ENV='development' during development.
process.env.NODE_ENV='production' after using build to do a production build.
GitHub Repo
No response
Steps to Reproduce
Nx Report
The text was updated successfully, but these errors were encountered: