Rookie Learning nodejs--Installation Nodejs

Source: Internet
Author: User

Since it's a rookie learning about node. js, before installing it, let's start by knowing what he is and why I want to learn about him.
Simply put, node. JS is the JavaScript that runs on the server. If you're a front-end programmer and you don't know a dynamic programming language like PHP, Python, or Ruby, then you want to create your own service, then node. JS is a great choice.
node. JS is JavaScript running on the server, and if you're familiar with JavaScript, you'll easily learn to node. js.
Of course, if you're a back-end programmer and want to deploy some high-performance services, learning node. JS is also a great option.

What does Node aim to solve?

Node's avowed goal is "to provide a simple way to build scalable network programs." What is wrong with the current server program? Let's do a math problem. In Java? In languages such as PHP, each connection generates a new thread, and each new thread may require 2 MB of companion memory. On a system with 8 GB of RAM, theoretically the maximum number of concurrent connections is 4,000 users. As your customer base grows, you must add more servers if you want your WEB application to support more users. This, of course, increases costs such as server costs, traffic costs, and labor costs. In addition to these cost increases, there is a potential technical problem that users may use different servers for each request, so any shared resources must be shared across all servers. For all these reasons, the bottleneck in the overall WEB application architecture, including traffic, processor speed, and memory speed, is the maximum number of concurrent connections that the server can handle.

Node solves this problem by changing the way it connects to the server. Each connection emits an event that runs in the Node engine's process instead of generating a new OS thread for each connection (and allocating some companion memory for it). Node claims that it will never deadlock, because it does not allow locks at all, and it does not directly block I/O calls. Node also claims that the server running it can support tens of thousands of concurrent connections.

Now that you have a program that can handle tens of thousands of concurrent connections, what can you actually build through Node? If you have a WEB application that needs to handle so many connections, it would be a "scary" thing! It's a question of "If you have this problem, then it's not a problem at all." Before answering the above questions, let's look at how Node works and how it's designed to work.

Download

https://nodejs.org/en/This is the website of node. js, we can download the direct access, I download is V4.4.3, if you like what version, find it yourself, online resources a lot of.

Installation

Right-click to install after download is complete.


Here the path everyone wants to change their own change, installed address does not require

The next step is to wait a little 1 minutes or so, and the installation will be successful. After the installation is complete, we open the taskbar, we can see our nodejs, and see if it is the same as mine.

Verify installation Success

How to test, we achieve to give small demo, if can come out effect, then congratulations success.
Open a program like node. js

Test 1

Enter the "2" to see if it is out, and if so, success.

Test 2

All say HelloWorld is the most familiar example in the world, then we use Nodejs to create an example of HelloWorld.
Create a new file to give the folder demo, and then create a filename that is not helloworld.js, add the following code

varrequire(‘http‘);http.createServer(function (req, res) {  res.writeHead(200, {‘Content-Type‘‘text/plain‘});  res.end(‘Hello World\n‘);}).listen(3000"127.0.0.1");console.log(‘这就是一个helloWorld的例子,运行在http://127.0.0.1/3000‘);

In the demo folder, hold down the SHIFT key while you click the right mouse button, choose to open the Command window here, enter helloworld.js you can see this one effect.

Summary

Specifically he can bring us nothing, we take a slow look, we will be full of nodejs, to tell you nodejs why these years so fire

Rookie Learning nodejs--Installation Nodejs

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.