events.js:85
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:44:10)
at 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
}));
});
请告诉我如何解决这个问题。
最佳答案
问题出在 Mac Yosemite 上的 hosts
文件上。为了纠正 /private/etc/hosts
中的行为,添加了以下行:
127.0.0.1 localhost
关于javascript - 有时会发生 gulp-webserver 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30233799/