1. Login website http://nodejs.org, install download installation package.
2. The installation process is basically direct "NEXT" on it.
3. After the installation is complete, you can use CMD (win+r and then enter CMD entry) to test if the installation is successful. Method: Enter node-vunder CMD, the version prompt is complete the installation of Nodejs.
4. Installation of NPM. The new version of Nodejs has been integrated with NPM, so NPM is installed as well. You can also use the cmd command line to enter "npm-v" to test for successful installation. For example, the version prompt will be OK.
5. The construction of conventional nodejs has been completed so far, so you can enter the "cmd" input "node" into node development mode, enter your Nodejs first sentence: "Hello World"-Input: Console.log (' Hello World ').
6.nodejs Install global module:npm install -g express
7. Next, we apply Nodejs to create the first application:
A. introduction of the required module: We can use the require directive to load the node. JS module.
B. Create server: The server can listen to the client's request, similar to Apache, Nginx and other HTTP server.
C. receiving requests and responding to the request server is easy to create, and the client can send HTTP requests using a browser or terminal, and the server returns the response data after receiving the request. The code is as follows:
var=require(' http ');
HTTP. Createserver(function(request, response){
//send HTTP header //HTTP status value: 200:ok//content type: Text/plainresponse. (200, { ' content-type ' : ' Text/plain ' //send response data "Hello World" response.end ( ' Hello world\n ' listen8888
Console. Log(' Server running at http://127.0.0.1:8888/');
Nodejs installation under Windows