How to do it...

First, build a small ExpressJS server application whose sole purpose will be to serve an HTML file and the Redux module:

  1. Create a new file named meal-time-server.js
  2. Include the ExpressJS and path module and initialize a new ExpressJS Application:
      const express = require('express') 
      const path = require('path') 
      const app = express() 
  1. Serve the Redux library on /lib path. Make sure that the path points to the node_modules folder:
      app.use('/lib', express.static( 
          path.join(__dirname, 'node_modules', 'redux', 'dist') 
      )) 
  1. Serve the client application on the root path /:
      app.get('/', (req, res) => { 
          res.sendFile(path.join( 
              __dirname, 
              'meal-time-client.html', 
          )) 
      }) 
  1. Listen for new connections on port 1337:
 app.listen( 1337, ...

Get MERN Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.