npm run dev報錯!!

先看下我的報錯

username:backend-atop-oa fulwin$ npm run dev

> [email protected] dev /Users/fulwin/Documents/codes/backend-atop-oa
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js

 10% building modules 1/1 modules 0 activeevents.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)
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/fulwin/.npm/_logs/2018-01-08T07_29_15_303Z-debug.log

我是先刪除了node_modules,重新npm install 沒用(重新安裝依賴)

rm -rf node_modules/
rm package-lock.json
npm cache clean --force
npm install

最後發現報錯是這個意思:意思是 沒有找到指定localhost

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

解決方法:config=>index.js中把host改爲127.0.0.1

在這裏插入圖片描述
然後再次試試 npm run dev

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章