Nodejs Classic Introduction--Hello World

Source: Internet
Author: User

1. Install the Nodejs.

Download the installation package to the official website (https://nodejs.org/en/). When the download is complete, click Install. Installed by default in the C:\Program Files\nodejs directory, I choose to install in the E:\nodejs directory.

2. Verify that the installation was successful.

Open the cmd Command Line window, switch to the E:\nodejs directory, dir will see that node and NPM are already installed, enter NODE/NPM-V to view the installed version. If the installation is successful.

3. First Nodejs Web site.

Create a new Helloworld.js file under the Nodejs directory with the following contents:

var http = require ("http");
Http.createserver (function (request, response) {
Response.writehead ($, {"Content-type": "Text/plain"});
Response.Write ("Hello World");
Response.End ();
}). Listen (666);
Console.log ("Nodejs starts to listen 666 port! You can access the Web by http://localhost:666 ");

Enter the command node Helloworld.js, which appears as follows:

Enter http://localhost:666 in the browser address bar to see Hello World

Nodejs Classic Introduction--Hello World

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.