var app = require(‘express’).createServer(), io = require(‘socket.io’).listen(app);
app.listen(3000);
app.get('/’, function (req, res) { res.sendfile(__dirname + ‘/index.html’); });
io.sockets.on('connection’, function (socket) { socket.emit('welcome’, { text: ‘OH HAI! U R CONNECTED!’ }); });
目录下面有index.html 报错内容是: TypeError: Arguments to path.join must be strings at f (path.js:204:15) at Object.filter (native) at exports.join (path.js:209:40) at exports.send (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\node_modules\connect\lib\middleware\static.js:129:20) at ServerResponse.res.sendfile (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\lib\response.js:186:3) at io.sockets.on.socket.emit.text (C:\Users\Administrator\nodejs\demo\socket.io_express\app.js:7:7) at callbacks (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\lib\router\index.js:272:11) at param (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\lib\router\index.js:246:11) at pass (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\lib\router\index.js:253:5) at Router._dispatch (C:\Users\Administrator\nodejs\demo\socket.io_express\node_modules\express\lib\router\index.js:280:5)
哪里出问题了额
八成是版本的问题,旧path.join可以传入非string参数,新path.join传入非string参数就会报这个错 http://nodejs.org/api/path.html#path_path_join_path1_path2 所以去看看socket.io有没有新版本