Beginner node

Because Node.js is a platform to run JavaScript code in the back end, so, you must first install Node environment in this machine.

Learn node, we must first install node, and its package management tools, which are both fools installation, Baidu click on install.

After installation, the terminal is opened, with

node -v

View node version

use

asl -v

View npm version

These are studying for the node.

node has two modes: 1, the command line mode 2, node interactive mode

Command-line mode: it is to build yourself a js file and then use the node + xxx.js to do this js file

node interactive mode: that is, the terminal input node and press Enter to enter the node we can enter the interactive mode js code above and then enter directly execute (twice ctrl + c to exit node interactive mode)

100 + 200 such as input a press enter, it will directly print out 300

But if you write js 100 + 200 + xxx.js then run in a node, it will not print out the results, if you want to print out the results, must be printed with console.log, which is also a command-line mode and interactive mode node the difference

We'll js code to be executed in strict mode, so no one should be added at the beginning of the file js

'use strict'

However, this seemed to be somewhat strenuous, each file will be added, there is a way to add node command parameter

node --use_strict xxx.js

This ensures that, js run in strict mode.

Add the following to establish a file called nodeTest bar, which built a hello.js, content is console.log ( "hello world");

Then open a terminal cd + filename

node  hello.js

We can see the terminal prints out a hello world,

Well, our first node program to write out! ! !

 Of course, you want convenience, we need to choose an IDE for developing node

So Liao teacher recommended that I now use vsCode! ! !

I have a better understanding, but there is little need to talk about, want to build .vscode file to a project directory, you need to select the directory, click on the left vscode debugging button (spider), then click on the Settings button , you can create .vscode file, then there is a launch.json file .vscode file is used to configure the

 

Guess you like

Origin www.cnblogs.com/fqh123/p/10991923.html