【问题标题】:gulp-webserver error occured sometimes有时会发生 gulp-webserver 错误
【发布时间】:2015-07-25 20:39:43
【问题描述】:

events.js:85
投掷者; // 未处理的“错误”事件
^
错误:getaddrinfo ENOTFOUND localhost
在 errnoException (dns.js:44:10)
在 GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)

当我运行'gulp'命令时,我遇到了这个错误,但我不知道如何解决它。我在运行gulp serve命令时也遇到了这个错误,所以我猜这个错误是由gulp-webserver引起的。

我在gulpfile.js 中的gulp serve 任务在这里。

gulp.task('serve', function() {
  gulp.src('app/')
     .pipe(webserver({
       livereload: true,
       directoryListening: true,
       open: true
     }));
});

请告诉我如何解决这个问题。

【问题讨论】:

  • 查看您的/etc/hosts 文件是否包含以下行:127.0.0.1 localhost
  • 我在我的 Mac Yosemite 中找不到 hosts 文件...
  • 对于优胜美地:/private/etc/hosts。参考:apple.stackexchange.com/questions/158117/…
  • 是的,我在那里搜索过。但只有 hosts.equiv 文件。这是正确的吗?
  • 不,它必须是没有扩展名的主机。没有它,DNS 将无法解析 localhost 名称。

标签: javascript node.js gulp


【解决方案1】:

问题在于 Mac Yosemite 上的 hosts 文件。为了纠正 /private/etc/hosts 中的行为,添加了以下行:

127.0.0.1   localhost

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多