NODE_ENV variable is automatically set to 'production' when deploying to Firebase hosting

Viewed 888

I am building a React.js app with Firebase and cannot figure out why when I am running locally, console.log(process.env.NODE_ENV) in App.js always returns development, but when deploying to hosting it is always production.

In my .env file, I have NODE_ENV='production' or NODE_ENV='development', which I change before I build depending on which Firebase project alias I am deploying to. When I deploy to my Firebase development project, I always get the NODE_ENV to be 'production' because (I have read that) NODE_ENV gets set when npm building automatically. Is there a way for me to prevent this so when I deploy, it will stay as development? Or maybe I am doing this wrong? Anything helps, thanks!

.env

# Live
REACT_APP_FIREBASE_LIVE_API_KEY=..
REACT_APP_FIREBASE_LIVE_AUTH_DOMAIN=..
REACT_APP_FIREBASE_LIVE_DATABASE_URL=..

# Test 
REACT_APP_FIREBASE_TEST_API_KEY=..
REACT_APP_FIREBASE_TEST_AUTH_DOMAIN=..
REACT_APP_FIREBASE_TEST_DATABASE_URL=..

# Other
GENERATE_SOURCEMAP=false
NODE_ENV='production'
0 Answers
Related