I want to run my create-react-app with express.js on node

Hello all,

I need help with running my React app on my VPS with node.
I have node running with passenger.

https://site.com will return the “hello world” correctly:
“Hello World. This page is running Node.js version: v12.22.5”

If I add the react index.html file to the /public folder it will show a blank screen and when inspected has all of the correct html. I understand this to be correct from the documentation and 2 topics from the forum.

I want to run my create-react-app with express.js on node but am I looking at it wrong? Will express.js compile with the react build? Or does express.js require node to be running it? Which is my belief. I’m thinking properly placed manifest.json or something.

I can run an express.js server in the app.js file with ports 80 and 443 and do all kinds of neat things but how do I get app.js to run react? I’m not getting how to access other folders including /public from my code.

I have done multiple “react with express” tutorials that either assume your server is setup for node+react or to sign up with someone else like Heroku.

Dreamhost’s documentation to get node and passenger running seems like they don’t realize people are going to use it for react. Or they are hoping customers will pay a tech to flip a switch. Or they won’t say it just won’t work.

But honestly, if it’s just pay another host service who does node, I will do that.
Who’s got the glue for this?

It seems your React part needs to be named app.js and loaded via Passenger (as per instructions you’ve followed to get a Node response already). This would then communicate to your Express backend which you will start manually or via script/crontab on it’s own (local) address:port.


A quick duckduckgo pulled this up:
Deploying a Simple React Application using FTP, FileZilla, & DreamHost | by Christine Tran | Medium

React’s App.js file is in the /src folder which sits next to the /public folder.
React’s App.js is called as a rendered component of React’s index.js.

If there is a index.html in the /public folder, it seams like the app.js file in the /root folder does not run. In the /public folder sits React’s index.html.

I wish it was that simple to swap out the app.js, but nope. Not that I can manage anyway. I need node to fire off the package.json in the root some how.

app.js is sitting here

Also, the duckduckgo search is just the way to compile static files from the build folder. Then upload them up to your web server. Not what I am trying to do. Unless express.js can run compiled with the compiled React build.

I know people have to of gotten this to work. I’m just not linking the pieces.

Passenger doesn’t override Apache other than when an app.js is served from the root directory.
If you don’t require app.js to be served directly on port 443 then don’t use Passenger. If you do, then move it.

I’m sorry, my directory tree wasn’t displayed correctly.




app.js <-- wants to sit here with passenger

Either way thanks for your help, sXi. I am going to rethink this and comeback to it later.