新人学习node.js求助
现在正在看《node.js入门经典》,里面有段代码不知道问什么无法执行 app.js代码如下 var express = require(‘express’);
var app = express();
var 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代码如下 <!DOCTYPE html> <html lang=“en”> <head> <meta charset=“utf-8”/> <title>Socket.IO Express Example</title> </head> <body> <h1>Socket.IO Express Example</h1> <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect(); socket.on(‘welcome’, function (data){ console.log(‘data.text’); }); </script>
</body>
</html>
总是报错无法找到/socket.io/socket.io.js