【问题标题】:grunt-contrib-connect server can't connect t localhostgrunt-contrib-connect 服务器无法连接到 localhost
【发布时间】:2014-09-03 17:39:27
【问题描述】:

我的 Gruntfile:

...
connect: {
  server: {
    options: {
      port: 8000,
      hostname: 'localhost',
      base: '.'
    }
  }
}
...

然后,当我运行grunt connect 时,我看到了:

❯ grunt connect
  Running "connect:server" (connect) task
  Started connect web server on http://localhost:8000

  Done, without errors.
❯

那就这样吧。如果我到达我的本地主机:8000。我看到 chrome 无法连接。

【问题讨论】:

    标签: gruntjs grunt-contrib-connect


    【解决方案1】:

    如果你想使用 grunt-contrib-connect 作为开发服务器,请查看keepalive 选项。

    根据文档:

    请注意,此服务器仅在 grunt 运行时运行。一次 grunt 的任务已经完成,web 服务器停止。这种行为可以 可以使用 keepalive 选项进行更改,并且可以通过以下方式临时启用 像grunt connect:keepalive一样运行任务。

    【讨论】:

    • keepalive 没有帮助。同样的事情。
    • 没关系,它确实有效,必须将keepalive 放入选项哈希中,我将它放入连接:哈希中。谢谢!
    猜你喜欢
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 2023-03-12
    • 2020-07-14
    • 2017-11-10
    • 2023-03-28
    相关资源
    最近更新 更多