In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shares with you the content of a sample analysis of the basics of node.js. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
What is NodeJS?
JS is a scripting language, and scripting languages require a parser to run. For JS written in a HTML page, the browser acts as a parser. For JS,NodeJS, which needs to run independently, it is a parser.
Each parser is a runtime environment that not only allows JS to define various data structures and perform various calculations, but also allows JS to do something using the built-in objects and methods provided by the runtime environment. For example, the purpose of JS running in a browser is to manipulate DOM, and the browser provides built-in objects such as document. The purpose of JS running in NodeJS is to manipulate disk files or build HTTP servers, and NodeJS provides fs, http and other built-in objects accordingly.
What's the use?
The author of NodeJS says that he created NodeJS to implement a high-performance Web server, and he first valued the advantages of the event mechanism and the asynchronous IO model, rather than JS. But he needs to choose a programming language to implement his idea, which does not have IO functionality and needs to be able to support event mechanisms. JS does not have a built-in IO feature, is naturally used to handle DOM events in browsers, and has a large group of programmers, so it becomes a natural choice.
As he expected, NodeJS became active on the server side, and a large number of NodeJS-based Web services emerged. On the other hand, NodeJS makes the front end like an artifact, and finally allows its capabilities to jump out of the browser window, and more front-end tools are springing up like bamboo shoots after a spring rain.
Therefore, for the front end, although not everyone has to write a server program with NodeJS, it can be as simple as using command interaction mode to debug JS code fragments, and complex enough to write tools to improve productivity.
How to install the installer
NodeJS provides some installers, all of which can be downloaded and installed here at nodejs.org.
Under Windows, select the installation file with the .msi suffix that matches the system version. Under Mac OS X system, select the installation file of the .pkg suffix.
Compilation and installation
There is no off-the-shelf installer available on Linux, and although some distributions can be installed in ways such as apt-get, they may not be able to install to the latest version. Therefore, under the Linux system, the following compilation methods are generally used to install NodeJS.
Make sure the Gmail + version is above 4.6 and the python version is above 2.6 under the system.
Download the latest NodeJS source code package for the tar.gz suffix from nodejs.org and extract it to a location.
Go to the directory you unzipped and compile and install using the following command.
$. / configure $make $sudo make install how to run
Open the terminal and type node to enter command interaction mode. You can enter a code statement and immediately execute and display the result, for example:
$node > console.log ('Hello Worldwide'); Hello World!
If you want to run a large piece of code, you can write a JS file and then run it. For example, there is the following hello.js.
Function hello () {console.log ('Hello Worldwide');} hello ()
After writing it, type node hello.js under the terminal to run it. The result is as follows:
$node hello.jsHello World! Thank you for reading! This is the end of this article on "sample Analysis of the basis of node.js". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.