run a react app locally code example

Example 1: how to create the rect project

npx create-react-app my-app
cd my-app
npm start

Example 2: how to create react app using yarn

yarn create react-app my-app

Example 3: create-react-app use npm

create-react-app my-project --use-npm

Example 4: create-react-app npm yarn

to override yarn
npx create-react-app my-app --use-npm

Example 5: setup the react on local machine

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
   entry: './main.js',
   output: {
      path: path.join(__dirname, '/bundle'),
      filename: 'index_bundle.js'
   },
   devServer: {
      inline: true,
      port: 8001
   },
   module: {
      rules: [
         {
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            query: {
               presets: ['es2015', 'react']
            }
         }
      ]
   },
   plugins:[
      new HtmlWebpackPlugin({
         template: './index.html'
      })
   ]
}