webpack-dev-server找不到本地主机 [英] webpack-dev-server can't find localhost

查看:153
本文介绍了webpack-dev-server找不到本地主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 webpack 开始使用 React ,但是当我尝试设置 webpack-dev-server <时总是遇到错误. /strong>.我跑了

I'm trying to get started with React using webpack, but keep running into an error when I try to set up webpack-dev-server. I ran

npm install webpack-dev-server

之后

webpack-dev-server

,命令行返回以下内容:

and the command line returns the following:

events.js:154
      throw er; // Unhandled 'error' event
      ^

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

关于这里发生的事情的任何线索吗?

Any clues on what is happening here?

我真的不知道webpack如何工作来尝试查找问题的根源,但是我也一直在使用PHP在80端口使用 MAMP 开发一个网站,我不知道不知道这是否可能是问题的一部分?

I don't really know how webpack works to try and search for the root of the problem, but I've also been developing a website using PHP at port 80 with MAMP, I don't know if this is maybe part of the issue?

推荐答案

解决了,原来我的主机文件(在Mac上的/etc/hosts下找到)缺少一行,因此webpack找不到localhost.我按照这些说明将其还原为默认设置现在可以了!

Solved, turned out my hosts file (found under /etc/hosts on a mac) had one line missing and so webpack couldn't find localhost. I restored it to its default following these instructions and it now works!

这篇关于webpack-dev-server找不到本地主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆