title: Error: Can't resolve 'os' in 'C:\Users\user\Downloads\Programming\Node.js\simple-ip\node_modules\multicast-dns' (webpack)
body: <p>I've got some super simple code taken from the <a href="https://github.com/mafintosh/multicast-dns#multicast-dns" rel="nofollow noreferrer"><code>multicast-dns</code></a> README and I want to test it, but in the browser. (I've already tested it locally and it works like a charm!) However, when I go to Webpack it, I get a lot of errors.</p>
  <p>Heres the logs:</p>
  <pre><code>assets by status 53.6 KiB [cached] 1 asset
  modules by path ./ 60.7 KiB
    modules by path ./node_modules/dns-packet/*.js 28.6 KiB 5 modules
    ./index.js 592 bytes [built] [code generated]
    ./node_modules/multicast-dns/index.js 4.93 KiB [built] [code generated]
    ./node_modules/thunky/index.js 1.03 KiB [built] [code generated]
    ./node_modules/events/events.js 13.8 KiB [built] [code generated]
    ./node_modules/ip/lib/ip.js 10 KiB [built] [code generated]
    ./node_modules/safe-buffer/index.js 1.63 KiB [built] [code generated]
  modules by path ../node_modules/ 53.6 KiB
    ../node_modules/buffer/index.js 47.6 KiB [built] [code generated]
    ../node_modules/base64-js/index.js 3.84 KiB [built] [code generated]
    ../node_modules/ieee754/index.js 2.1 KiB [built] [code generated]
  
  WARNING in configuration
  The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
  You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
  
  ERROR in ./node_modules/ip/lib/ip.js 5:9-22
  Module not found: Error: Can't resolve 'os' in 'C:\Users\user\Downloads\Programming\Node.js\bundle_mdns\node_modules\ip\lib'
  
  BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
  This is no longer the case. Verify if you need this module and configure a polyfill for it.
  
  If you want to include a polyfill, you need to:
          - add a fallback 'resolve.fallback: { &quot;os&quot;: require.resolve(&quot;os-browserify/browser&quot;) }'
          - install 'os-browserify'
  If you don't want to include a polyfill, you can use an empty module like this:
          resolve.fallback: { &quot;os&quot;: false }
   @ ./node_modules/dns-packet/index.js 7:11-24
   @ ./node_modules/multicast-dns/index.js 1:13-34
   @ ./index.js 1:11-35
  
  ERROR in ./node_modules/multicast-dns/index.js 2:12-28
  Module not found: Error: Can't resolve 'dgram' in 'C:\Users\user\Downloads\Programming\Node.js\bundle_mdns\node_modules\multicast-dns'
   @ ./index.js 1:11-35
  
  ERROR in ./node_modules/multicast-dns/index.js 5:9-22
  Module not found: Error: Can't resolve 'os' in 'C:\Users\user\Downloads\Programming\Node.js\bundle_mdns\node_modules\multicast-dns'
  
  BREAKING CHANGE: webpack &lt; 5 used to include polyfills for node.js core modules by default.
  This is no longer the case. Verify if you need this module and configure a polyfill for it.
  
  If you want to include a polyfill, you need to:
          - add a fallback 'resolve.fallback: { &quot;os&quot;: require.resolve(&quot;os-browserify/browser&quot;) }'
          - install 'os-browserify'
  If you don't want to include a polyfill, you can use an empty module like this:
          resolve.fallback: { &quot;os&quot;: false }
   @ ./index.js 1:11-35
  
  webpack 5.18.0 compiled with 3 errors and 1 warning in 1534 ms
  </code></pre>
  <p>It seems like the error is about the package I installed, multicast-dns, which uses the <code>os</code> core module. I know that if I had control over the multicast-dns package I could switch <code>os</code> to the browserify os module, but i don't. Is there a way to fix this without having the clone <code>multicast-dns</code>?</p>
  <p>Thanks!</p>