Search code examples
reactjsnpmcreate-react-appyarnpkg

How to run create-react-app build version


I have created a test React application and I started it with the create-react-app. I am starting it with with yarn start, but that starts the debug version of the application. I did npm run build and it created the build folder, however when I do yarn start from the /build folder, it still starts the debug version of the application. I need this for testing performance with the optimized version. How can I solve this?


Solution

  • You're trying to move from a development build to a production build with create-react-app you need to deploy it using a web server, I would recommend using Heroku or a droplet or you can use Netlify which has a simple set up procedure using the below commands:

    cd project-name
    npm run build
    
    npm install netlify-cli -g
    netlify deploy
    

    Follow command line prompts and choose yes for new project and ./build as your deploy folder and voila you have a production React app!

    You can host the app locally using apache, nginx, express