Node.js environment configuration [detailed]

Environment configuration of Node.js

Before environment configuration, let's review the components of JavaScript in the browser: It can be divided into two parts 核心语法 (循环,函数...)and web API (DOM BOM). As shown in the following figure:
insert image description here

Review why JavaScript code can be executed in the browser:

Because different browsers contain different JavaScript parsing engines:

举个栗子:Chrome allows us to develop the most commonly used browser, why can it become the most commonly used browser, and where is it friendly to us? In fact, Google Chrome's V8 parsing engine is the best engine for parsing JavaScript code among many browsers.

List the analysis engines of the current mainstream browsers:

  1. Chrome browser => V8
  2. Firefox browser = "OidnMonkey (Odin Monkey)
  3. Safari browser => JScode
  4. IE browser = "charkra (Chakra)

tips:The V8 parsing engine of Chrome browser is the nicest!

Why JavaScript can manipulate DOM and BOM

Because each browser has built-in API functions such as DOM and BOM, JavaScript in the browser can call them.

insert image description here

The JavaScript runtime in the browser

Using Chrome as an example

insert image description here
Summarize:

  1. The V8 engine is responsible for parsing and executing JavaScript code.
  2. The built-in API is a special interface provided by the running environment, which can only be called in the running environment to which it belongs.

What is Node.js

Node.js 是One based on the Chrome V8 engine JavaScript 运行环境.

Node URL:https://nodejs.org/zh-cn/

JavaScript runtime environment in Node.js

  1. Browsers are JavaScript 前端运行环境.
  2. Node.js is JavaScript 后端运行环境.
  3. 无法调用In-browser APIs like DOM and BOM in Node.js.

insert image description here

What Node.js can do

Based on node, we can use many frameworks to develop faster:

  1. Based on the Express framework ( http://www.expressjs.com.cn/), you can quickly build web applications
  2. Based on the Electron framework ( https://electronjs.org/), you can build cross-platform desktop applications
  3. Based on the restify framework ( http://restify.com/), you can quickly build API interface projects
  4. Read, write and manipulate databases, create useful command line tools to assist front-end development, etc...

How to learn Node.js?

Node.js learning path:
JavaScript 基础语法+ Node.js built-in API modules (fs, path, http, etc.) + third-party API modules (express, mysql, etc.)

After knowing how to learn, let's install Node.js. After installation, you can run JavaScript code in node.

First, open the official website of node: https://nodejs.org/zh-cn/, we will enter this interface:

insert image description here
Then we click the LTS download and install button on the left. After downloading, we click to open the target file, and just keep going to next.切记默认路径最好不要改变。

Determine whether the installation of node.js is successful

We Windows + Ropen cmdthe terminal, enter in it node –v, and then execute the command. If the output is the version number of the node.js you installed, it means the installation is successful.

As shown below:
insert image description here

So how to execute JavaScript code in node:

Very simple, the fastest way is in the directory where our js is located, 摁着shift + 点击右键, we can power shall 终端see , open it, and then enter node + js的文件名称to execute JavaScript code in node.

Finally, let's take a look at the common shortcut keys and commands in the terminal:

hot key:

  1. Use the ↑ key to quickly navigate to the last executed command
  2. Use the tab key to quickly complete the path
  3. Use the esc key to quickly clear the currently entered command
  4. Enter the cls command to clear the terminal

Order:

  1. You can enter the drive letter by adding a colon to the drive letter name (default: C drive) eg: D:you can enter the D drive
  2. cd 加文件路径: You can enter the folder where this file is located.

Keep reviewing, keep being excellent, be practical and do things seriously; pay attention to Sanlian and keep updating~~~
insert image description here

Guess you like

Origin blog.csdn.net/egg_er/article/details/122817625