title: npm run cannot find module graceful-fs
body: <p>im currently on a djangoRest and React course. I have experience on npm and python but this error is something i can't solve.
  Everithing went well until i &quot;npm run dev&quot;</p>
  <p><strong>package.json file</strong></p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;name&quot;: &quot;frontend&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;dev&quot;: &quot;webpack --mode development --watch&quot;,
      &quot;build&quot;: &quot;webpack --mode production&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@babel/core&quot;: &quot;^7.13.16&quot;,
      &quot;@babel/preset-env&quot;: &quot;^7.13.15&quot;,
      &quot;@babel/preset-react&quot;: &quot;^7.13.13&quot;,
      &quot;babel-loader&quot;: &quot;^8.2.2&quot;,
      &quot;react&quot;: &quot;^17.0.2&quot;,
      &quot;react-dom&quot;: &quot;^17.0.2&quot;,
      &quot;webpack&quot;: &quot;^5.34.0&quot;,
      &quot;webpack-cli&quot;: &quot;^4.6.0&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@babel/plugin-proposal-class-properties&quot;: &quot;^7.13.0&quot;,
      &quot;@material-ui/core&quot;: &quot;^4.11.3&quot;,
      &quot;@material-ui/icons&quot;: &quot;^4.11.2&quot;,
      &quot;react-router-dom&quot;: &quot;^5.2.0&quot;
    }
  }
  
  </code></pre>
  <p><strong>webpack.config.js file</strong></p>
  <pre><code>const path = require(&quot;path&quot;);
  const webpack = require(&quot;webpack&quot;);
  
  module.exports = {
    entry: &quot;./src/index.js&quot;,
    output: {
      path: path.resolve(__dirname, &quot;./static/frontend&quot;),
      filename: &quot;[name].js&quot;,
    },
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: &quot;babel-loader&quot;,
          },
        },
      ],
    },
    optimization: {
      minimize: true,
    },
    plugins: [
      new webpack.DefinePlugin({
        &quot;process.env&quot;: {
          // This has effect on the react lib size
          NODE_ENV: JSON.stringify(&quot;production&quot;),
        },
      }),
    ],
  };
  
  </code></pre>
  <p><strong>Error</strong></p>
  <pre><code>npm run dev
  
  &gt; frontend@1.0.0 dev E:\Programacion cursos\Harvard\React&amp;JavaScript\VsCode\react_django\frontend
  &gt; webpack --mode development --watch
  
  &quot;JavaScript\VsCode\react_django\frontend\node_modules\.bin\&quot; no se reconoce como un comando interno o externo,
  programa o archivo por lotes ejecutable.
  internal/modules/cjs/loader.js:883
    throw err;
    ^
  
  Error: Cannot find module 'E:\Programacion cursos\Harvard\webpack\bin\webpack.js'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
      at Function.Module._load (internal/modules/cjs/loader.js:725:27)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
      at internal/main/run_main_module.js:17:47 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
  }
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! frontend@1.0.0 dev: `webpack --mode development --watch`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the frontend@1.0.0 dev script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  </code></pre>
  <p>Im guessing the problem is where npm is searching for webpack.js archive. Currently the route of <code>webpack.js</code> is <code>E:\Programacion cursos\Harvard\React&amp;JavaScript\VsCode\react_django\frontend\node_modules\webpack\bin\webpack.js</code> but i don't know why is searching for that module in <code>E:\Programacion cursos\Harvard\webpack\bin\webpack.js</code></p>
  <p>I want to change where npm is searching for <code>webpack</code> module, but i dont know how. I tried <code>npm link webpack</code> and then <code>npm unlink webpack</code> to install it again but it doesn't work. If anyone know how to do it, please help me. Thanks!</p>
  <p><strong>Edit</strong>
  I solve one of the problems. Change the <code>node_module\.bin</code> folder to <code>node_module\bin</code></p>
  <p>In <code>node_modules</code>, the <code>graceful-fs</code> module is there. ¿What can i do?
  The error is:</p>
  <pre><code>Error: Cannot find module 'graceful-fs'
  Require stack:
  - C:\Users\matia\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js       
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
      at Function.Module._load (internal/modules/cjs/loader.js:725:27)
      at Module.require (internal/modules/cjs/loader.js:952:19)
      at require (internal/modules/cjs/helpers.js:88:18)
      at Object.&lt;anonymous&gt; (C:\Users\matia\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:77:13)
      at Module._compile (internal/modules/cjs/loader.js:1063:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
      at Module.load (internal/modules/cjs/loader.js:928:32)
      at Function.Module._load (internal/modules/cjs/loader.js:769:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
      'C:\\Users\\matia\\AppData\\Roaming\\npm\\node_modules\\webpack\\bin\\webpack.js'
    ]
  </code></pre>