Webpack-dev-server failed to start (vents.js:183)

after I recently installed webpack-dev-server , I always failed to start and tried all sorts of methods, but it didn"t work.

Local environment

  • macOS 10.12.6
  • node v8.11.4
  • npm v5.6.0
  • I installed
  • with cnpm

error prompt

vents.js:183
      throw er; // Unhandled "error" event
      ^

Error: getaddrinfo ENOTFOUND localhost
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)

dependence

  found information  most of them say port conflicts) 
  • set the port to another 9000
  • install other versions of webpack-dev-server
  • I use webpack-dev-middleware servers that work with express can use
  • none of the above can solve


    problem solving

    in the end, it's a question of / node_modules relying on packages. In the final analysis, it's a problem of network .

    I used to rely on the installation of the network (China Mobile) shared by my mobile phone. Today the use of broadband network (Great Wall Broadband) installation depends on a success.

    eliminate the problem of cnpm . Both npm and cnpm have tried to use broadband successfully.

    summarize

    the straightforward point debug is a process of constantly eliminating and locating the cause

    .

    it usually takes a few steps to encounter such a magical problem

    1. locate BUG

      1. browser error and developer tool error
      2. find "code that may cause errors" through comments
    2. look for ideas

      1. No idea search engine looking for ideas
    3. Select and solve problems

      1. (without damaging the current environment) keep trying all possible ways
      2. if you still can't solve it, try something that you don't think is feasible (such as reopening a project).
      3. if you're not in a hurry, leave the code for a few days. Maybe I'll just be all right.
    Menu