Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run production react app in local with local back-end

Tags:

reactjs

I have seen using production react app with server in local.

But mostly I found the way is running production react app using express.js with Heroku.

How to running production react app with server in local without any change of code?

like image 645
JillAndMe Avatar asked Jul 09 '19 09:07

JillAndMe


1 Answers

When you run npm run build your console should actually say something like the following

The build folder is ready to be deployed.
You may serve it with a static server:

npm install -g serve
serve -s build

The build script is building your entire app into the build folder, ready to be statically served. However actually serving it require some kind of static file server, like the one they propose.

After running the command serve -s build you can access your production build at localhost (on the specified port).

You can of course run whatever static file server you like, I usually use express for this, however serve seems like the easiest option to just serve your statics files with a single command.

like image 138
Monika Mangal Avatar answered Oct 22 '22 03:10

Monika Mangal