Running a React app as a background process
<p>I'm completely new to deploying front-end code and thus the question.
I have a React App which I need to run as a background process, however I'm a little confused about the how to do this.
I run a npm script </p>

<pre><code>npm run build
</code></pre>

<p>to build, minify and serve the project on a server. 
The relevant code for the build process is this.</p>

<pre><code>"prebuild": "npm-run-all clean-dist test lint build:html",
"build": "babel-node tools/build.js",
"postbuild": "babel-node tools/distServer.js"
</code></pre>

<p>This is the code inside the distServer.js</p>

<pre><code>import express from 'express';
import path from 'path';
import open from 'open';
import compression from 'compression';


const port = 3000;
const app = express();

app.use(compression());
app.use(express.static('dist'));

app.get('*', function(req, res){
  res.sendFile(path.join(__dirname, '../dist/index.html'));
});

app.listen(port, function(err){
  if(err){
    console.log(err);
  }else{
    open(`http://localhost:${port}`);
  }
});
</code></pre>

<p>This works and the project runs, however the moment I close my terminal the project stops.
The build process creates, three files,</p>

<pre><code>index.html
index.js
styles.css
</code></pre>

<p>Now if I navigate to the index.html and open it in a browser, but naturally, nothing shows up. So I'm assuming that I'd have to run it as a node process. How do I do this on the production server and run it as a background process so that even if I exit the terminal the app continues to run.
I have checked this issue,
<a href="https://stackoverflow.com/questions/12701259/how-to-make-a-node-js-application-run-permanently">How to make a node.js application run permanently?</a></p>

<p>But this has a javascript file as the entry point, in my case it's a html file. I'm not sure how can I modify my scripts to run the front-end app permanently as a background process. Any help appreciated.</p>