Learn Nodejs while walking (Basic Introduction) and nodejs beginners

Source: Internet
Author: User

Learn Nodejs while walking (Basic Introduction) and nodejs beginners

1. What is Node. js?

Nodejs, or node, is a platform based on ChromeJavaScript runtime. It is used to conveniently build fast and scalable network applications. Node. js uses event-driven, lightweight and efficient non-blocking I/O models, making it ideal for data-intensive real-time applications running on distributed devices.

Node. javascript has created a precedent for javascript modular development. The early javascript requirements were very simple, basically written as functions, followed by process-oriented development. Later, the idea of object-oriented development was gradually introduced, then I wrote the class slowly. The emergence of Node. js gave javascript the concept of modular development.

2. install and use Nodejs

2.1 installation

Download the corresponding installation file on the official node. js website (https://nodejs.org/download. Here, we mainly describe the installation of Nodejs on Windows.

Download idea.

After the installation is complete, you will find that the installation directory has npm, so you do not need to install npm any more.

After the installation is successful, run the command: node-v on the command line, and the command line prints the published document number, for example:


After the installation is successful, run the command: node-v on the command line, and the command line prints the published document number, for example:




2.2 execution

Open node. js commandprompt




Go to the working directory and enter the command npmxxx. js.



3. Simple Example

3.1 first program: helloworld

Create the helloworld. js file in the working directory and write it to: console. log ('helloworld ');

Execute nodehelloworld. js in the command line

Output:


3.2 helloworld in http mode

Create the hello. js file in the working directory and write the file:




Run node hello. js in the command line and enter http: // localhost: 3000/in the browser. The output of the browser is shown in.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.