npm run scripts

Update the package.json file to add the following npm run scripts for development and production.

mern-simplesetup/package.json:

"scripts": {    "development": "nodemon",    "build": "webpack --config webpack.config.client.production.js 
                 && webpack --mode=production --config      webpack.config.server.js",    "start": "NODE_ENV=production node ./dist/server.generated.js"}
  • npm run development: This command will get Nodemon, Webpack, and the server started for development
  • npm run build: This will generate the client and server code bundles for production mode (before running this script, make sure to remove the devBundle.compile code from server.js)
  • npm run start: This command will run the bundled code in production

Get Full-Stack React Projects 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.