What is a node. Js
Node.js is a JavaScript runtime environment based on the Chrome V8 engine that uses an event-driven, non-blocking I/O model. To put it bluntly, Node.js allows programs written in JS language to run on the server side, and provides file reading and writing, operating system and other functions.
Install the node
Rookie under https://www.runoob.com/nodejs/nodejs-install-setup.html don’t dwell on the reference document.
Run the node
- The base command runs node
- Output the node XXX file in the command line of the current file.
- Code Runner plug-in command
- Nodemon content is hot updated
npm install -g nodemon
- As you can see, re-changing the content automatically updates the content after saving it.
Global object
The Buffer Buffer
Js has no binary data type and must use binary data when processing file streams. The buff is used to create a cache dedicated to binary data.
- Creating a Buffer object
- attribute
- Buffer class method
- Buffer object method
modular
Asynchronous I/o
IO refers to Input/output in a computer.
path
- attribute
- methods
fs
- Obtaining File Information
- Read file Write file
3. Stream operation reads and writes files
6. Copy files
7. Directory operations
url
Setting up the HTTP Server
The response (res)
Response static data
Response dynamic resource
- In response to JSON
- The response HTML
Request (the req)
- Get
- Post
The path to distribute
package
1. The concept
A package is a further abstraction on a modular basis, encapsulating a separate function for release, update, dependency management, and version control. NPM is used in development to address package publishing and acquisition requirements.
- specification
- package.json
4. Create packages
npm init -y