create-react-app npm run start in production mode. Maybe not possible?

user4412054 picture user4412054 · Mar 17, 2018 · Viewed 9.2k times · Source

I need to run the server like I simply do with:

npm run start

but I need to use the production mode. Is this possible?

In ember or angular it is possible. How to do in create-react-app?

I tried npm run start --prod but nothing.

Answer

Franck Jeannin picture Franck Jeannin · Jul 30, 2019

The best option is probably to do a normal production build and then run it locally.
First install an HTTP server:

npm install serve -g

Then:

npm run build
serve -s build

By default, it will run on port 5000 so your local URL is http://localhost:5000