title: Module build failed Cannot find module '@babel/preset-env'
body: <p>I was working on my react application with set up babel. Unfortunately while setting it up using yarn and when I build my <code>bundle.js</code> file, I run into some problems:</p>
  
  <pre><code>ERROR in ./src/app.js
  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  Error: Cannot find module '@babel/preset-env' from '/Users/react-file/Desktop/indecision'
      at Function.resolveSync [as sync] (/Users/react-file/Desktop/indecision/node_modules/resolve/lib/sync.js:89:15)
      at resolveStandardizedName (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
      at resolvePreset (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:58:10)
      at loadPreset (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/files/plugins.js:77:20)
      at createDescriptor (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
      at /Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
      at Array.map (&lt;anonymous&gt;)
      at createDescriptors (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
      at createPresetDescriptors (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
      at presets (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
      at mergeChainOpts (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:320:26)
      at /Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:283:7
      at Generator.next (&lt;anonymous&gt;)
      at buildRootChain (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/config-chain.js:120:29)
      at buildRootChain.next (&lt;anonymous&gt;)
      at loadPrivatePartialConfig (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/partial.js:95:62)
      at loadPrivatePartialConfig.next (&lt;anonymous&gt;)
      at Function.&lt;anonymous&gt; (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/partial.js:120:25)
      at Generator.next (&lt;anonymous&gt;)
      at evaluateSync (/Users/react-file/Desktop/indecision/node_modules/gensync/index.js:244:28)
      at Function.sync (/Users/react-file/Desktop/indecision/node_modules/gensync/index.js:84:14)
      at Object.&lt;anonymous&gt; (/Users/react-file/Desktop/indecision/node_modules/@babel/core/lib/config/index.js:41:61)
      at Object.&lt;anonymous&gt; (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:151:26)
      at Generator.next (&lt;anonymous&gt;)
      at asyncGeneratorStep (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:3:103)
      at _next (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:5:194)
      at /Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:5:364
      at new Promise (&lt;anonymous&gt;)
      at Object.&lt;anonymous&gt; (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:5:97)
      at Object._loader (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:231:18)
      at Object.loader (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:64:18)
      at Object.&lt;anonymous&gt; (/Users/react-file/Desktop/indecision/node_modules/babel-loader/lib/index.js:59:12)
  </code></pre>
  
  <p>Here's my <code>package.json</code>:</p>
  
  <pre><code>{
    "name": "Box",
    "version": "1.0.0",
    "main": "index.js",
    "license": "MIT",
    "scripts": {
      "server": "live-server public/",
      "build": "webpack --watch",
      "build-babel": "babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch"
    },
    "dependencies": {
      "babel-cli": "^6.26.0",
      "babel-core": "^6.26.3",
      "babel-loader": "^8.1.0",
      "babel-preset-env": "^1.7.0",
      "babel-preset-react": "^6.24.1",
      "live-server": "^1.2.1",
      "react": "^16.13.1",
      "react-dom": "^16.13.1",
      "validator": "^13.0.0",
      "webpack": "^4.43.0"
    },
    "devDependencies": {
      "@babel/core": "^7.9.6",
      "webpack-cli": "^3.3.11"
    }
  }
  </code></pre>
  
  <p>Here's my <code>webpack.config.js</code> const path = require('path');</p>
  
  <pre><code>module.exports = {
    entry: './src/app.js',
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.js'
    }, 
    module: {
        rules: [{
            loader: 'babel-loader', 
            test: /\.js$/,
            exclude: /node_modules/
        }]
    }
  };file"
  </code></pre>
  
  <p>And here's my <code>.babelrc</code> file:</p>
  
  <pre><code>{
      "presets": [
          "env",
          "react"
      ]
  }
  </code></pre>
  
  <p>Any idea what's wrong with this?</p>