1. 安装 (windows)
https://nodejs.org/en/download/
check环境变量path是否包含C:\Program Files\nodejs\;
2.hello world
helloworld.js:
console.log("Hello World");
run :node helloworld.js
output:Hello World
3.express应用
run:app目录下runnpm install express
会生成node_modules目录
创建server.js
var http = require('http');
http.createServer(function (request, response) {
// 发送 HTTP 头部
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// 发送响应数据 "Hello World"
response.end('Hello World\n');
}).listen(8888);
// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');
run:node server.js
浏览器访问: http://127.0.0.1:8888/
输出:Hello World