- npm init y
初始化包,引进packet.json文件
- npm安装http包
npm install http --save
- 创建server.js文件,编写代码
'use strict'
var http=require("http");
http.createServer(function(request,response){
response.writeHead(200,{"Content-Type":"text/plain"});
response.write("Hello World");
response.end();
}).listen(10231);
- 运行server.js
node server.js