First Nodejs Program

Source: Internet
Author: User

My first Nodejs program: Hello World

var http = require ("http"); Http.createserver (function (request, response) {  Response.writehead (200, {") Content-type ":" Text/plain "});  Response.Write ("Hello World");  Response.End ();}). Listen (8000); Console.log (' Server is runing at http://127.0.0.1:8000 ');

Record the installation process:

    1. Go to http://nodejs.org/download/download the appropriate installation package, I downloaded this node-v0.10.0-x86.msi
    2. Create a Nodejs directory on your computer x disk and install the downloaded program into this directory
    3. Locate the PATH variable and add the X:\nodejs
    4. After adding PATH, create a new variable Node_path variable value X:\nodejs\node_modules

Here, even if the configuration is complete, create a new Nodejs folder in the D-disk, creating a Helloworld.js file in this folder to add the above JS content

Next click on the system's Start menu to run the cmd command:

D:   d:\> CD Nodejsd:\>nodejs>node helloworld.js    

Then appears: Server running at Http://127.0.0.1:8000/is successful.

Finally, open http://127.0.0.1:8000/in the browser.

Transferred from: http://iw3c.com/archive/my-first-nodejs-code-helloworld/

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.