【问题标题】:Grunt server no error, not workingGrunt 服务器没有错误,不工作
【发布时间】:2014-09-16 22:48:30
【问题描述】:

Grunt 没有给我一个错误,但是当我导航到该 ip 地址时,那里什么也没有。

我知道 node 可以工作,因为我使用 node 创建了一个准系统服务器,它在同一个端口上服务并且工作正常。

当我在准系统服务器运行时尝试运行 grunt 时,它说该端口已被占用,所以我知道它至少认为它在该端口上提供服务。

当我在本地机器上使用相同的文件时,它工作得很好,我可以导航到端口并且它工作正常。准系统服务器也是如此。

关于可能是什么原因的任何线索?顺便说一句,我正在使用 yo 来安装 angular-bootstrap。

对于准系统服务器,我只是这样做:

DIR=~/proj2/www
FILE=hello.js
mkdir -p $DIR
cat <<EOF >$DIR/$FILE
var http = require('http');
var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/html"});
  response.end("<html><body>Hello World</body></html>");
});

server.listen(9000);
EOF

【问题讨论】:

    标签: node.js gruntjs npm


    【解决方案1】:
    // Change this to '0.0.0.0' to access the server from 
    hostname: 'localhost'
    

    好吧,正如代码注释所说,您只需将 'localhost' 更改为 '0.0.0.0'。

    谢谢,我;你帮了大忙!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-07
      • 2014-04-21
      • 2014-11-03
      • 2013-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多