0

我按照本教程在ubuntu上安装了node.js,安装成功。但是当我输入 node echo-server.js 时,我收到以下错误:

module.js:340  
    throw err;  
      ^ 
Error: Cannot find module '../../lib/ws/server'  
    at Function.Module._resolveFilename (module.js:338:15)    
    at Function.Module._load (module.js:280:25)  
    at Module.require (module.js:362:17)  
    at require (module.js:378:17)  
    at Object.<anonymous> (/home/jci/node/joyent-node-283d735/echo-server.js:2:10)  
    at Module._compile (module.js:449:26)  
    at Object.Module._extensions..js (module.js:467:10)  
   at Module.load (module.js:356:32)  
   at Function.Module._load (module.js:312:12)  
   at Module.runMain (module.js:487:10)  

回显服务器代码:

 var sys = require("util")  
  , ws = require('../../lib/ws/server');  

var server = ws.createServer({debug: true});  

 // Handle WebSocket Requests  
 server.addListener("connection", function(conn){  
  conn.send("Connection: "+conn.id);  

   conn.addListener("message", function(message){  
    conn.send("<"+conn.id+"> "+message);  

    if(message == "error"){  
      conn.emit("error", "test");  
}

}); });

server.addListener("error", function(){ console.log(Array.prototype.join.call(arguments, ", ")); });

server.addListener("断开连接", function(conn){ server.broadcast("<"+conn.id+">断开连接"); });

server.listen(8000);

但是缺少 lib/ws/server。但是我从哪里得到它??我猜我的 node.js 安装中没有 Web 套接字服务器。

谢谢斯内哈
_

4

0 回答 0