1

I created react app using create-react-app. I have deployed to aws.

How can I run it in production without using server like apache or nginx ?

Thank You.

3
  • Use Node.js. There is no option to run SPA without server. Commented Apr 20, 2017 at 11:35
  • I have node js. How can I give project path, for the ip address or domain name? Commented Apr 20, 2017 at 11:37
  • You should use AWS tag to reach required community. We use nginx proxy. Commented Apr 20, 2017 at 11:42

1 Answer 1

2

You should install nginx on your EC2 instance.

Then, run npm run build. It will generate a build folder, that then should be used as nginx vhost webroot.

npm run build

Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

Simple as that.

Or,

For environments using Node, the easiest way to handle this would be to install serve and let it handle the rest:

npm install -g serve serve -s build

Sign up to request clarification or add additional context in comments.

1 Comment

I did this : npm install -g serve serve -s build . But it is running running server locally on AWS EC2, where as we want it to be global. Is there anything else which I have to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.