0

你好堆垛机。

我正在我正在开发的网站上实现 node.js 和 nowjs。几周前,我开始在 localhost 上开发该网站,一切正常。几天前,我将文件传输到了 rackspace 托管的云服务器,操作系统为 Ubuntu 12.04 LTS(Precise Pangolin)。

现在我无法让 nowjs 主页上的简单聊天示例正常工作!当我尝试运行服务器端脚本时,我不断收到以下错误:

[RangeError: 超出最大调用堆栈大小]

我的代码中没有递归循环,我尝试在整个互联网上寻找我的问题的解决方案,但没有运气。

这是我的两个示例文件 - 来自 nowjs 官方网站上的 chat/helloworld 示例的 ac/p。(http://nowjs.com/doc/example)

服务器.js

var html = require('fs').readFileSync(__dirname+'/helloworld.html');
var server = require('http').createServer(function(req, res){
  res.end(html);
});
server.listen(8080);

var nowjs = require("now");
var everyone = nowjs.initialize(server);

everyone.now.distributeMessage = function(message){
  everyone.now.receiveMessage(this.now.name, message);
};

helloworld.html

<!DOCTYPE html>
<html lang="en">
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>

<script>
$(document).ready(function(){

  now.receiveMessage = function(name, message){
    $("#messages").append("<br>" + name + ": " + message);
  }

  $("#send-button").click(function(){
    now.distributeMessage($("#text-input").val());
    $("#text-input").val("");
  });

  now.name = prompt("What's your name?", "");

});
</script>
</head>

<body>
  <div id="messages"></div>
  <input type="text" id="text-input">
  <input type="button" value="Send" id="send-button">
</body>
</html>

我的问题:

  1. 有没有人在托管的 Web 服务器上运行 nowjs 时遇到同样的问题?
  2. 在托管 Web 服务器上运行 nowjs 时,是否有任何我可能不知道的依赖项?

谢谢你。

4

1 回答 1

0

我终于解决了这个问题。所需要的只是使用最新的稳定版本(v0.4.12)重新安装节点。

于 2012-06-05T20:29:28.950 回答