开发者

connect.staticProvider Problem

I'm trying this code:

var connect = require("connect");
var io = require("socket.io");
var spawn = require("child_process").spawn;

var server = connect.createServer(
    connect.favicon(),
    connect.logger(),
    connect.staticProvider(__dirname + '/public')
);
server.listen(8000);

var socket = io.listen(server, {flashPolicyServer: false});
var tail = spawn("tail", ["-f", "./nohup.out"]);

tail.stdout.on("data", function(data) {
    socket.broadcast(data.toString("utf8"));
});

But when I try to run this I got an error:

Nathan-Camposs-MacBook-Pro:log Nathan$ node app.js  

node.js:134  
        throw e; // process.nextTick error, or 'error' event on first tick  
        ^  
TypeError: Object function createServer() {  
  if ('object' == typeof arguments[0]) {  
    return new HTTPSServer(arguments[0], Array.prototype.slice.call(arguments, 开发者_Go百科1));
  } else {
    return new HTTPServer(Array.prototype.slice.call(arguments));
  }
} has no method 'staticProvider'
    at Object.<anonymous> (/Users/Nathan/Sites/log/app.js:8:10)
    at Module._compile (module.js:407:26)
    at Object..js (module.js:413:10)
    at Module.load (module.js:339:31)
    at Function._load (module.js:298:12)
    at Array.<anonymous> (module.js:426:10)
    at EventEmitter._tickCallback (node.js:126:26)
Nathan-Camposs-MacBook-Pro:log Nathan$ 


I don't really know the connect library. But this documentation says, that it's static not staticProvider (in the version 1.0).

So your server creating part should be:

var server = connect.createServer(
    connect.favicon(),
    connect.logger(),
    connect.static(__dirname + '/public')
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜