npm run dev 报错:getaddrinfo ENOTFOUND localhost

mac:manage-web gwl$ npm run dev

> [email protected] dev /Users/gwl/Desktop/manage-web
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 10% building modules 1/1 modules 0 activeevents.js:174                            
      throw er; // Unhandled 'error' event
      ^

Error: getaddrinfo ENOTFOUND localhost
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1457:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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:
npm ERR!     /Users/gwl/.npm/_logs/2019-08-30T06_24_05_056Z-debug.log
mac:manage-web gwl$ 

原因:

hosts文件中缺少 127.0.0.1和localhost的绑定

转载于:https://my.oschina.net/gwlCode/blog/3099793

你可能感兴趣的:(运维)