Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How can I conditionally check if React app is in 'production' or 'dev' in a Heroku environment?

$
0
0

Here is the code:

if (process.env.NODE_ENV === 'production') {  module.exports = require('./keys_prod');} else {  module.exports = require('./keys_dev');}

keys_prod IS on the server

keys_dev is only on my local machine

Here is the problem:

when the app starts up on Heroku I get the following:

ERROR in ./src/environment/keys.js 8:2-40 Module not found: Error: Can't resolve './keys_dev' in '/app/src/environment'

Heroku Config vars

I have the following set in the Heroku config vars:

enter image description here

package.json

my package.json scripts section

"scripts": {"start": "react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject","heroku-postbuild": "npm run build"  },

saw this but I am on heroku 22 - so that won't work


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>