Nodejs installation under Windows

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.