Window NodeJs installation

1, download NodeJs

Download the official website: http://nodejs.cn/download/

2, installation

Double-click next full installation.

The installation is complete, view the version command in cmd execute the following command as follows

C: \ the Users \ Administrator> the Node - v 
# execution results 
. # V10 14.1

Here nodejs on the installation finished.

3, create a small program

In any folder, I am here to do presentations on the desktop, create a js file named main.js.

js document reads as follows

the require HTTP = var ( ' HTTP ' ); 

http.createServer ( function (Request, Response) { 

    // HTTP headers are sent 
     // HTTP status values: 200 is: the OK
     // Content Type: text / Plain 
    response.writeHead ( 200 is , { ' the Content-the Type ' : ' text / Plain ' }); 

    // send a response "the Hello World" 
    Response.End ( ' the Hello World \ n- ' ); 
}) the listen (. 8888 ); 

// print terminal following information 
the console.log ( 'Server running at http://127.0.0.1:8888/');

After creating main.js complete, cut in cmd window to the desktop path, execute the following command

main.js the Node 
# execution results 
# Server running AT HTTP: // 127.0.0.1:8888/

In the browser, enter http://127.0.0.1:8888/ can see

Hello World

Case Reference Address: http://www.runoob.com/nodejs/nodejs-http-server.html

Guess you like

Origin www.cnblogs.com/kawhileonardfans/p/10966870.html