The project uses fetch.js and uses webpack to package and report the error Cannot resolve module ‘dns’

  node.js, question
  1. Describe your problem
    The project uses fetch.js and uses webpack to package and report the error Cannot resolve module ‘dns’

  2. Attach relevant codes
    require(‘fetch’);

  3. Post error message

    WARNING in ./~/fetch/~/encoding/lib/iconv-loader.js
     Critical dependencies:
     9:12-34 the request of a dependency is an expression
     @ ./~/fetch/~/encoding/lib/iconv-loader.js 9:12-34
     
     ERROR in ./~/fetch/lib/fetch.js
     Module not found: Error: Cannot resolve module 'dns' in /home/tigerb/github/easy-vue/node_modules/fetch/lib
     @ ./~/fetch/lib/fetch.js 8:10-24
     
     ERROR in ./~/fetch/lib/fetch.js
     Module not found: Error: Cannot resolve module 'net' in /home/tigerb/github/easy-vue/node_modules/fetch/lib
     @ ./~/fetch/lib/fetch.js 12:10-24

Didn’t you say circular dependency appeared in log?

Please check whether the configuration in resolve of your webpack is correct.

PS: What is your fetch.js? How did you call dns and net, the two node modules? These two modules should not be able to run in the browser. If you are writing a server node, there is no need to use a webpack.