title: Not Sure How to Start and Deploy ReactJS App on Production Server with ExpressJS
body: <p>Locally, I use ExpressJS on port 3001 and then start my react app with <code>npm start</code> which runs the development server on port 3000. This allows me to route requests as a proxy from 3000 to 3001.</p>
  
  <p>For production, I installed Ubuntu NodeJS 6.12.13 on 16.04 on a DigitalOcean Droplet and then installed Nginx and PM2.</p>
  
  <p>In my Nginx <code>default</code> file I have set the following:</p>
  
  <pre><code>location / {
      proxy_pass http://localhost:3001;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
  }
  </code></pre>
  
  <p>I've moved over my Express and React setup and added the Express server to the PM2 startup. Nginx is being used as a reverse proxy server to use Express on port 3001. Here is the PM2 startup (<code>www</code> is the name of the server file which runs Express).</p>
  
  <p><a href="https://i.stack.imgur.com/kLEO4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kLEO4.jpg" alt="enter image description here"></a></p>
  
  <p>When I load my domain, I receive the Express default page:</p>
  
  <p><a href="https://i.stack.imgur.com/TjCQr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TjCQr.jpg" alt="enter image description here"></a></p>
  
  <p>Now I'm not sure how to start the react app, because it doesn't seem logical to start it using <code>npm start</code> and keep the terminal open for a production server. I need to see my React app when I visit the domain instead of the Express message.</p>
  
  <p>I've found articles which mention to use <code>npm run build</code> but they don't explain how to then run the React app. Sorry I'm new to this, but any help would be appreciated. Thank you.</p>