Professional 5-nodejs first day (nodejs installation, what is nodejs, nodejs characteristics distinguish repl environment, nodejs instruction execution js files, nodejs and the javascript, http module)

1, nodejs installation

 Nodejs version 1.1 to detect node -v (version: Version)

 1.2 path configuration variable environment nodejs of (the current version is its own installation configuration environment variable)

 1.3 npm (node ​​package mangment) versions prior node node package management tools are two separate npm modules are installed separately, it is now npm package to node installation program.

2. What is nodejs?

 2.1  nodejs is javascript operating environment, there is a platform nodejs of js execution similar to other server-side language such as: java php python and #c etc.

 2.2 javascript: is running in the browser's object-based, event-driven scripting language.

       nodejs: js itself is a platform runtime environment.

 2.3 nodejs: to http, fs, path, url, querystring module. nodejs platform is to imitate os (operating systems) to achieve the function of each server is used to service

3, nodejs features

 3.1 event-driven mechanism

  3.2 Single-threaded (asynchronous operation efficient use of resources cpu)

  3.3 Non-blocking mechanism

4, repl environment 

  4.1 repl: can be run interactively environment

  4.2 repl quit environment: ①, the instruction ".exit" ②, ctrl + c : double-click.

5, node run the command js file

  5.1 dos common instructions:

          cls: Clear Screen

          cd: change the file path (to exit to the previous folder.)

          dir: statistical list of the current folder

 5.2 node instructions: Build execute .js file

6 difference, nodejs and the javascript

 6.1 javascript is object-based, event-driven scripting language that runs in the browser side.

 6.2 nodejs is a platform support javascript running environment. nodejs package different modules, such as http, fs, path modules. It is used to make a server-side function.

7, http module

 http: hypertext transfer protocol

 Module: nodejs platform functions, thrown out to developers.

 http module can create a sever server

 1, http modules explain

 2, req, res Detailed

 3, the role of the port number

   The same server can accept multiple applications, as long as the different port number, you can access different services. (You can create different port numbers of different services and applications)

   (1--1000) port numbers are to the system (win System) services. ftp: 21, 80-port, printer port 443, in general, are 4-digit port number

 4,req.url

   By default, the value of "/"

    If there is data after the host name (localhost) and port number, then the value is behind req.url port number data

 5,res.write()

   res:response

   res.write (); // (server sends data to the client)

 6,res.end()

   end (): the end of the server to stop the end of the response to the client. Or it can be done before the end of the final output.

  

Guess you like

Origin www.cnblogs.com/songbingqi/p/12056758.html