How to configure and express Node.js
This section describes how to configure the node with the express
Configuration Node.js
1, the installation package download Node.js Node.js Download
2, in accordance with the process step by step installation package go
Continue to click Next to OK
3, the terminal can be seen inside the version installed Node
Enter the following statement:
4, create an application using Node.js
(1) Use http.createServer () method to create server and bind port 8888 using the listen method.
Create a 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/');
(2) to use in the terminal node server.js
(3) Next, open the browser to access http://127.0.0.1:8888/, that says you will see a "Hello World" page
Configuration express
Using the common command to install npm Node.js Web frame modules express
$ npm install express