0

I am a newbie of node.js
and I am trying to run a simple chat application but I got an this error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'now'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/home/mier/Desktop/node/helloworld_server.js:8:16)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)

here is my code:

var html = require('fs').readFileSync(__dirname+'/helloworld.html');
var server = require('http').createServer(function(req, res){
res.writeHead(200,{'Content-Type':'text/html'});
  res.end(html);
});
server.listen(1200);

var everyone = require('now').initialize(httpServer);

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

my html code:

<!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="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>

I've been searching on the internet for the solution but I cant find any solution.
thanks in advance...

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by sandip@vnc
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.