Deploy and install nodejs in windows

Source: Internet
Author: User

 

Nodejs, as a new background language, has many attractive points:

 

RESTful API

Single thread

Non-blocking IO

Google V8

Event-driven

 

The processing model of Node is different from the concurrency model of commonly used operating system threads. The thread-based network is relatively inefficient and hard to use. Compared with the traditional thread model that requires 2 MB of thread stacks for each new connection, Node shows better memory efficiency under high load. In addition, the Node user does not have to worry about the process deadlock, because there is no lock concept in Node. Node has almost no function to directly execute IO operations, and the process will never be blocked, because there is no blocking, and even if it is not an expert, it can write a fast system.

 

Node is designed to be influenced by Ruby's Event Machine and Python's Twisted and is somewhat like it. Node pays more attention to the event model. It uses the event loop as the language structure rather than the class library. In other systems, there is usually a blocking call to start the event loop. At the beginning of the script, you can use the callback function to define an action, and then call the blocked call (such as EventMachine:: run () to start the service. Node does not have such a function call to start the event loop. After executing the input script, it automatically enters the event loop. This is a bit like JavaScript in the browser. The event loop is hidden from users.

 

 

Install and deploy nodejs on Linux. The related documents are complete and the entire process is relatively simple. However, to deploy nodejs on windows, you have to work hard before. Now, it's okay, with official support, everything becomes simple:

 

First: download this nodejs exe file: http://nodejs.org/dist/v0.5.2/node.exe (currently still unstable Version)

 

Next, enter the file directory of node.exe and create a new hello. js file. The content is as follows:

 

Var http = require ('http'); http. createServer (function (req, res) {res. writeHead (200, {'content-type': 'text/plain '}); res. end ('Hello World \ n ');}). listen (1337, "127.0.0.1"); console. log ('server running at http: // 127.0.0.1: 1337 /');

Then, open the logging command line and enter the directory of node.exe. then, you can add node.exe to the system path, so that you can execute it anywhere and execute the file above.

 

Node hello. js

 

At this time, we can see:

 

 

Open your browser:

 

 

Well, everything is ready. You can start!

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.