node. JS Getting Started

Source: Internet
Author: User

First, go to http://nodejs.org to download the installation. The version I'm under is 0.10.28. The installation is simple and the next step is.

My installation directory is C:\Program Files\nodejs. At this point, use the NODE-V command to view the installed version

First, HelloWorld

Create a new file in the node. JS installation directory hello.js a line of code

1 console.log(‘hello, nodejs.‘) ;

Go to the command line console and go to the node. js directory to knock node Hello.js

The console outputs "Hello, Nodejs."

Second, the web version of the HelloWorld

Create a new http.js in the node. JS installation directory with the following code

1 2 3 4 5 6 varhttp = require("http"); http.createServer(function(request, response) {     response.writeHead(200, {"Content-Type": "text/html"});     response.write("Hello World!");     response.end(); }).listen(8000);

Start the service on the command line and tap node Http.js

Then open the browser address bar input http://localhost:8000/, see the page output Hello world! It was a success.

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.