Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a production build of my react app locally?

My package.json has the following script:

"build": "sh -ac '. .env.${REACT_APP_ENV}; react-scripts build'"

When I run yarn build I get the following error:

sh: .env.: No such file or directory

The .env file is in the top level of my project directory as expected. Any ideas?

like image 346
pea-sea Avatar asked Sep 19 '25 13:09

pea-sea


1 Answers

You could also use the NODE_ENV variable, it gives you the environment mode.

I don't know if you're using create-react-app, but if you are (once you have built your app), you can use serve to run the production version:

$ npm install -g serve

$ serve -s build


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!