title: Critical dependency: the request of a dependency is an expression for socket.io and express
body: <p>I installed Laravel and run <code>npm run watch</code> command, it returned:</p>
  
  <pre><code>ERROR in ./node_modules/destroy/index.js
  Module not found: Error: Can't resolve 'fs' in 'C:\xampp\htdocs\checknpm\node_modules\destroy'
  
  ERROR in ./node_modules/express/lib/request.js
  Module not found: Error: Can't resolve 'net' in 'C:\xampp\htdocs\checknpm\node_modules\express\lib'
  
  ERROR in ./node_modules/engine.io/lib/server.js
  Module not found: Error: Can't resolve 'uws' in 'C:\xampp\htdocs\checknpm\node_modules\engine.io\lib'
  </code></pre>
  
  <p>Then I set some configuration in laravel <code>webpack.mix.js</code>:</p>
  
  <pre><code>mix.webpackConfig({
      target: "node",
  });
  </code></pre>
  
  <p>and it retuned:</p>
  
  <pre><code>WARNING in ./node_modules/socket.io/lib/index.js
  113:11-32 Critical dependency: the request of a dependency is an expression
  
  WARNING in ./node_modules/node-gyp-build/index.js
  13:9-32 Critical dependency: the request of a dependency is an expression
  
  WARNING in ./node_modules/node-gyp-build/index.js
  20:15-54 Critical dependency: the request of a dependency is an expression
  
  WARNING in ./node_modules/express/lib/view.js
  81:13-25 Critical dependency: the request of a dependency is an expression
  
  ERROR in ./node_modules/engine.io/lib/server.js
  Module not found: Error: Can't resolve 'uws' in 'C:\xampp\htdocs\checknpm\node_modules\engine.io\lib'
  </code></pre>
  
  <p>and lastly I added:</p>
  
  <pre><code>mix.webpackConfig({
      target: "node",
      externals: {
          uws: "uws",
          ws: "ws",
      },
  });
  </code></pre>
  
  <p>when I run <code>npm run watch</code> it returned:</p>
  
  <pre><code>WARNING in ./node_modules/socket.io/lib/index.js
  113:11-32 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/socket.io/lib/index.js
   @ ./resources/js/bootstrap.js
   @ ./resources/js/app.js
   @ multi ./resources/js/app.js ./resources/sass/app.scss
  
  WARNING in ./node_modules/express/lib/view.js
  81:13-25 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/express/lib/view.js
   @ ./node_modules/express/lib/application.js
   @ ./node_modules/express/lib/express.js
   @ ./node_modules/express/index.js
   @ ./resources/js/bootstrap.js
   @ ./resources/js/app.js
   @ multi ./resources/js/app.js ./resources/sass/app.scss
  </code></pre>
  
  <p>I tried different ways but it didn't work! I want to have a socket relation with Laravel however it sends me these errors and it doesn't even let me to run socket. how can I fix it?</p>