title: React build issue, ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js):
body: <p>I am trying to build react application from scratch using Webpack 4</p>
  <p>I am getting following error when I try to build. Whereas babel-core is already installed, I also tried installing @babel/core but it didn't work</p>
  <pre><code>ERROR in ./src/index.js
  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  Error: Cannot find module '@babel/core'
      at Function.Module._resolveFilename (module.js:538:15)
      at Function.Module._load (module.js:468:25)
      at Module.require (module.js:587:17)
      at require (internal/module.js:11:18)
      at Object.&lt;anonymous&gt; (/Users/digvijay.upadhyay/digvijayu/react_webpack_4_from_scratch/node_modules/babel-loader/lib/index.js:5:15)
      at Module._compile (module.js:643:30)
      at Object.Module._extensions..js (module.js:654:10)
      at Module.load (module.js:556:32)
      at tryModuleLoad (module.js:499:12)
      at Function.Module._load (module.js:491:3)
   @ multi (webpack)-dev-server/client?http://localhost:8080 ./src main[1]
  Child html-webpack-plugin for &quot;index.html&quot;:
       1 asset
      Entrypoint undefined = ./index.html
      [./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html] 500 bytes {0} [built]
      [./node_modules/lodash/lodash.js] 527 KiB {0} [built]
      [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 489 bytes {0} [built]
      [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {0} [built]
  ℹ ｢wdm｣: Failed to compile.
  </code></pre>
  <p><strong>webpack.config.js</strong></p>
  <pre><code>const HtmlWebPackPlugin = require(&quot;html-webpack-plugin&quot;);
  
  const htmlPlugin = new HtmlWebPackPlugin({
    template: &quot;./src/index.html&quot;,
    filename: &quot;./index.html&quot;
  });
  
  module.exports = {
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: &quot;babel-loader&quot;
          }
        }
      ]
    },
    plugins: [htmlPlugin]
  };
  </code></pre>
  <p>edit: Added the package json file to the question
  <strong>package.json</strong></p>
  <pre><code>  &quot;devDependencies&quot;: {
          &quot;babel-core&quot;: &quot;^6.26.3&quot;,
          &quot;babel-loader&quot;: &quot;^8.0.0&quot;,
          &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
          &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,
          &quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,
          &quot;webpack&quot;: &quot;^4.17.1&quot;,
          &quot;webpack-cli&quot;: &quot;^3.1.0&quot;,
          &quot;webpack-dev-server&quot;: &quot;^3.1.6&quot;
        },
        &quot;dependencies&quot;: {
          &quot;@babel/core&quot;: &quot;^7.0.0&quot;,
          &quot;path&quot;: &quot;^0.12.7&quot;,
          &quot;react&quot;: &quot;^16.4.2&quot;,
          &quot;react-dom&quot;: &quot;^16.4.2&quot;
        }
  
  {
    &quot;name&quot;: &quot;boiler-plate-react-webpack-4&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;webpack-dev-server --mode development --open --display-error-details&quot;,
      &quot;build-dev&quot;: &quot;webpack --mode development&quot;,
      &quot;build-prod&quot;: &quot;webpack --mode production&quot;,
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;babel-core&quot;: &quot;^6.26.3&quot;,
      &quot;babel-loader&quot;: &quot;^8.0.0&quot;,
      &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
      &quot;babel-preset-react&quot;: &quot;^6.24.1&quot;,
      &quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,
      &quot;webpack&quot;: &quot;^4.17.1&quot;,
      &quot;webpack-cli&quot;: &quot;^3.1.0&quot;,
      &quot;webpack-dev-server&quot;: &quot;^3.1.6&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.0.0&quot;,
      &quot;path&quot;: &quot;^0.12.7&quot;,
      &quot;react&quot;: &quot;^16.4.2&quot;,
      &quot;react-dom&quot;: &quot;^16.4.2&quot;
    }
  }
  </code></pre>