webpack-dev-server 找不到本地主机 [英] webpack-dev-server can't find localhost
问题描述
我正在尝试使用 webpack 开始使用 React,但是在我尝试设置 webpack-dev-server<时一直遇到错误/强>.我跑了
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屋!