Create a package.json file containing following contents.

{
    "name": "app_name",
    "version": "1.0.0",
    "description": "",
    "main": "app.js",
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "express": "^4.16.3",
        "path": "^0.12.7",
        "react-color": "^2.18.1"
    }
}
npm install

Now Create app.js file containing following contents.

const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, 'build')));

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

app.listen(3000);

Install pm2 for forever running node app.

npm i pm2 -g

Upload build (npm run build) folder along with app.js

Start Server

pm2 start app.js

now app is running on specified port in app.js

Spread the love
Last modified: August 15, 2020

Comments

Write a Reply or Comment

Your email address will not be published.