1.安装express
在文件夹mypro路径下的cmd窗口运行“npm install express –save”
2.添加文件app.js到mypro文件夹
/app.js
var app = require('express')();
var http = require('http').Server(app);
app.get('/', function(req, res){
res.send('<h1>Hello world</h1>');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
运行node app.js,打开http://localhost:3000/,显示hello world
3.安装socket.io
在上面的CMD窗口运行:“npm install –save socket.io”
4.添加index.html到mypro文件夹
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {