2.5 node.js looking back

2.5 node.js looking back

What is node.js? As mentioned in the previous subsection 2.4, it is a runtime that can be independent of the browser's javascript. Ryan Dahl, the father of nodejs, later developed the deno framework using the Go language, and was frantically complained by a Chinese developer. This feel seems to be similar to what I encountered in some time, as shown below:

Here is talking about the environment configuration of using Visual Studio Code to develop js programs, and the npm package manager. Let's talk about the development environment setup process first:

1 Install nodejs, first find:

Open the website, download it, and install:

2 Install Visual Studio Code:

Install it:

3 Install the Visual Studio Code plug-in Code Runner. Code Runner is used to run source files, such as js, C++, python, etc. Open the package manager, enter Code Runner, find and install:

Open a sample js file and enter the following code:

console.log("hello world!");console.info(123);
var x=1,y=2;console.log(x,y);

Click the triangle button at the upper right corner of the figure below to run the program:

You can see the program output.

Let's talk about npm, what is npm? npm=node package manager. Common npm commands can be used for package installation, update, uninstallation, etc., and can also be used for package initialization. For example , to install the electron package in the previous section , enter the following command in the command line tool:

npm install electron -g

The following -g parameter means global installation. Without the g parameter, it will be installed in the currently active folder on the command line. After a while, the installation can be completed, provided that you are abroad and the domestic internet speed is very slow. We can use the mirror image of Taobao, and enter the following command:

npm install cnpm -g --registry=http://registry.npm.taobao.org

In the future, you can use the cnpm command to install the npm package, download resources directly from the server in China, and the speed is very fast. At this time, the command to install electron is:

cnpm install electron -g

After the installation is complete, you can play happily. You can also use the cnpm command to install some other common packages, speed levers. Another commonly used function of npm is to initialize the package, run the command line tool in a certain project folder, and enter:

npm init

In my own experience, generate a package.json file in this folder, and open it to see the setting content. The previous section used for engineering package, specify the name of the project to generate electron, the dependent libraries (package) and so on.

Several node libraries we may use:

  • express develops a website server to handle user access, input, query and other background functions;
  • rpio provides access control to Raspberry Pi GPIO
  • serialport can be used to read the computer serial port
  • Electron supports the development of windows, Linux, and Mac OS client programs, as mentioned in the previous section .
  • cordova is used to develop mobile client

The node knowledge system is also very complicated and huge, and it can't be learned overnight, so let's talk about it first because of space.

The young man asked the master: Why are some people full of motivation when under pressure, but I just want to run away when under pressure? Master: Look at this candle, a gust of wind can blow him out, and the fire outside, the more the wind blows, the fire The more prosperous, do you know why? Youth: Do you mean that life is like this fire. When your heart is big enough, the pressure will make you stronger and stronger? Master: The wax flame has strong heat dissipation and low combustion temperature. It is in the dynamic combustion zone. When it is blown, it will increase the heat dissipation and cause the temperature to drop, which makes the burning speed decrease and extinguish. The outside fire center has a very high temperature and is in the diffusion combustion zone. Increasing the blowing can enhance the mass transfer and increase the oxygen supply capacity, so that the combustion speeds up and the fire temperature becomes higher. Youth: Master, your house is now!

Reference: https://cloud.tencent.com/developer/article/1418910 2.5 node.js looking back-Cloud + Community-Tencent Cloud