I'd like to manually change the value of the NODE_ENV
environment variable when I build my React app in development node (yarn run start
).
No, as per create-react-app@3.4.1 at least, this is not possible. Excerpt from the docs:
There is also a built-in environment variable called
NODE_ENV
. You can read it fromprocess.env.NODE_ENV
. When you runnpm start
, it is always equal to 'development', when you runnpm test
it is always equal to 'test', and when you runnpm run build
to make a production bundle, it is always equal to 'production'. You cannot override NODE_ENV manually. This prevents developers from accidentally deploying a slow development build to production.