Getting Started with node. JS Development under Windows (1)

Source: Internet
Author: User

It's okay. Churn node. js, ran a Hello world, and I hereby record it.

Installing the node. JS Environment under Windows

The http://nodejs.org can be downloaded to the installation package on the node website. I am Win7 64, visit node website, can see the latest version number is 0.12.7, click Install to be able to download the MSI file, and then double-click to be able to install.

The installation process is very easy. Select all options and Next will do.

MSI will install the NPM (node package Manager) and will help you set up environment variables, add Node, NPM and so on to the path, so you just open the command line form. will be able to work.

The Start menu will include a node. js folder, for example, as seen in:

Click the "node. js command Prompt" menu. will go into node. JS's command-line environment. For example, as seen in:

You can use node and NPM directly here.

If you enter node and enter, you enter node's interactive environment. Be able to enter some JavaScript commands to see. For example Console.log ("Hello node.js!"). There's a reaction, huh. The effect of entering node is equivalent to clicking the node. JS menu in the Start menu.

Assuming you enter NPM and enter, you'll see the use of NPM help. For example, with:

This is the basis of the environment. Very easy, and then we have to go insane, walk usual. Let's have a HelloWorld.

HelloWorld site

The code is so simple:

// 引入http模块var http = require("http"); // 创建server,指定处理client请求的函数http.createServer(    function(request, response) {         response.writeHead(200, {"Content-Type": "text/plain"});         response.write("Hello World!");         response.end();     }).listen(8000); console.log("Hello World is listening at port 8000");

Save As Helloworld.js, and then in the command-line environment of node. js. Enter the Helloworld.js folder, execute node helloworld.js, the site will be able to execute.

We simply demonstrate the sample and return "Hello world!" for whatever request. Text string, you can enter "http://localhost:8000" in the browser to see the effect, I here is Jiangzi:

Nothing special, an ugly one, right. What about the HTTP module, see here http://nodejs.org/dist/v0.12.7/docs/api/http.html.

Well, that's how the wonderful World started ... The Start menu has the node. JS Documentation submenu, which enables direct access to the node. JS online documentation, where many other highlights can start.

Next time we will analyze the HelloWorld further. This paper introduces the basic program structure of Nodejs and some knowledge points used by HelloWorld.

Getting Started with node. JS Development under Windows (1)

Related Article

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.