node.js と now.js を正常にインストールしました。
now.js については、次のようにしました。
npm install now -g
npm install now (had to add this one. Without it, I get a "Cannot find now..." error message)
ノードサーバーを起動し、次のような server.js ファイルを提供すると:
var httpServer = require('http');
httpServer.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('Node is ok');
res.end();
}).listen(8080);
console.log('Server runs on http://xxxxx:8080/');
すべて順調。
今、このファイルに now.js の基本的な使い方を追加しようとしています。
var nowjs = require("now");
var everyone = nowjs.initialize(httpServer);
everyone.now.logStuff = function(msg){
console.log(msg);
}
同じフォルダーに index.html ファイルを作成します (テスト目的)。
<script type="text/javascript" src="nowjs/now.js"></script>
<script type="text/javascript">
now.ready(function(){
now.logStuff("Now is ok");
});
</script>
今回は、サーバーを起動したときに端末に表示されるのは次のとおりです。
Server runs on http://xxxxx:8080/
[TypeError: Object #<Object> has no method 'listeners']
TypeError: Object #<Object> has no method 'listeners'
at Object.wrapServer (/home/xxxx/node_modules/now/lib/fileServer.js:23:29)
at [object Object].initialize (/home/xxxx/node_modules/now/lib/now.js:181:14)
at Object.<anonymous> (/home/xxxx/server.js:10:22)
at Module._compile (module.js:444:26)
at Object..js (module.js:462:10)
at Module.load (module.js:351:32)
at Function._load (module.js:309:12)
at module.js:482:10
at EventEmitter._tickCallback (node.js:245:11)
全くの初心者ですのでご了承ください。
ご協力ありがとうございました