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.