How to set React's process.env.NODE_ENV to production on AWS Beanstalk

Viewed 253

I have set up an AWS Beanstalk environment where I have deployed a React application. I have successfully done it by packaging the project folder to a .zip file and uploading it via the console, as well as through an AWS CodePipeLine.

The problem is that the variable process.env.NODE_ENV is set to development, instead of production when I do this. This means I cannot detect if the application is being run in a production environment instead of development.

I have also tried running npm run build to create a build folder of the project, then zipping and uploading that, but my environment throws an error when I do that.

So, my question is: does anyone know what steps I need to take to ensure that process.env.NODE_ENV is set to production when running on AWS Beanstalk?

Alternatively, if this cannot be done, is there another way to make React differentiate between development and production environment?

0 Answers
Related