title: Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module 'babel-preset-react'
body: <p>I'm stuck with the following error when trying to build a react app with Webpack4 and Babel7.</p>
  <pre><code>ERROR in ./src/index.js
  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  Error: Cannot find module 'babel-preset-react' from '/Users/me/Desktop/reflask'
  - If you want to resolve &quot;react&quot;, use &quot;module:react&quot;
  - Did you mean &quot;@babel/react&quot;?
      at Function.module.exports [as sync] (/Users/me/Desktop/reflask/node_modules/resolve/lib/sync.js:43:15)
      at resolveStandardizedName (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
      at resolvePreset (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/files/plugins.js:58:10)
      at loadPreset (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/files/plugins.js:77:20)
      at createDescriptor (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
      at items.map (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/config-descriptors.js:109:50)
      at Array.map (&lt;anonymous&gt;)
      at createDescriptors (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
      at createPresetDescriptors (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
      at passPerPreset (/Users/me/Desktop/reflask/node_modules/@babel/core/lib/config/config-descriptors.js:58:96)
   @ multi (webpack)-dev-server/client?http://localhost:8080 ./src main[1]
  </code></pre>
  <p>I've tried removing the node_modules folder and reinstalling dependencies with the following.</p>
  <p><strong>Terminal</strong></p>
  <pre><code>rm -rf node_modules/
  npm install
  </code></pre>
  <p><strong>Configuration</strong></p>
  <p><strong>package.json</strong></p>
  <pre><code>{
    &quot;name&quot;: &quot;reflask&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;webpack-dev-server --open --mode development&quot;,
      &quot;build&quot;: &quot;webpack&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.1.0&quot;,
      &quot;@babel/preset-env&quot;: &quot;^7.1.0&quot;,
      &quot;@babel/preset-react&quot;: &quot;^7.0.0&quot;,
      &quot;babel-loader&quot;: &quot;^8.0.2&quot;,
      &quot;html-loader&quot;: &quot;^0.5.5&quot;,
      &quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,
      &quot;prop-types&quot;: &quot;^15.6.2&quot;,
      &quot;webpack&quot;: &quot;^4.19.1&quot;,
      &quot;webpack-cli&quot;: &quot;^3.1.1&quot;,
      &quot;webpack-dev-server&quot;: &quot;^3.1.9&quot;
    },
    &quot;dependencies&quot;: {
      &quot;bootstrap&quot;: &quot;^4.1.3&quot;,
      &quot;react&quot;: &quot;^16.5.2&quot;,
      &quot;react-bootstrap&quot;: &quot;^0.32.4&quot;,
      &quot;react-dom&quot;: &quot;^16.5.2&quot;,
      &quot;react-router-dom&quot;: &quot;^4.3.1&quot;
    }
  }
  </code></pre>
  <p><strong>webpack.config.js</strong></p>
  <pre><code>const HtmlWebPackPlugin = require(&quot;html-webpack-plugin&quot;);
  module.exports = {
      module: {
          rules: [
              {
                  test: /\.js$/,
                  exclude: /node_modules/,
                  use: {
                      loader: &quot;babel-loader&quot;,
                      options: {
                          presets: ['react']
                      }
                  }
              },
              {
                  test: /\.html$/,
                  use: [
                      {
                          loader: &quot;html-loader&quot;
                      }
                  ]
              }
          ]
      },
      plugins: [
          new HtmlWebPackPlugin({
              template: &quot;./src/index.html&quot;,
              filename: &quot;./index.html&quot;
          })
      ]
  };
  </code></pre>
  <p><strong>index.js</strong></p>
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import App from './js/components/App.jsx';
  import registerServiceWorker from './registerServiceWorker';
  
  ReactDOM.render(&lt;App /&gt;, document.getElementById('root'));
  registerServiceWorker();
  </code></pre>
  <p><strong>.babelrc</strong></p>
  <pre><code>{
    &quot;presets&quot;: [&quot;@babel/preset-env&quot;, &quot;@babel/preset-react&quot;]
  }
  </code></pre>