This is the 15th day of my participation in the August More text Challenge. For details, see: August More Text Challenge

Persistence is the key to study, notes are the soul, review the old to know new, from time to time, review the knowledge points, deepen memory, twice the result with half the effort!

Here are some notes to learn about Node.js. There will be more notes to learn about node.js in the future

This article to learn some of the foundation of Node.js and actual combat: batch rename file method implementation

learningNode.jsSome of the basics of

1. Fs module Built-in module

NPM I Third-party moduleCopy the code

Custom modules written by yourself (write JS files)

2. Read the file

  1. Read files asynchronously (readFile)

Solve back to hell with promise

  1. Synchronous file readingreadFileSync
var nr = fs.readFileSync('./b.txt'.'utf-8')
console.log(nr)
Copy the code
  1. Read the file as a stream

Read the video file and display the progress by percentage readvideo.js

Copy small files first read and then copy copyfile.js

  1. Write data
  • ① Write data asynchronously

Copy the large file copyBigfile.js

3. httpThe module

Methods:

Create a service:

createServer((req,res) = >{
  // Set a response header:
  res.writeHead(200, {"Content-Type":"text/html; charset=utf-8"});
  req.url  // Get the url requested by the client (address other than the protocol port domain name http://www.baidu.com?main=22&pid=90)
  res.write(); // Respond to the user's request
  res.end(); // End the response
})
    get("Url path", callback method)The // method requests the server data
Copy the code
  • showPage.js

Exercises:

  • ①[‘1′,’,’,’,’,’,’,’2′,’3′,’9′,’,’,’] move the comma to the right

  • ② There is an array with 1000 elements, and the number stored is 1-999. Please find out the number that is repeated

Read more

Read more:

[Node.js] Efficiency tools – NVM & NRM, etc.

[node.js] Package management tool NPM & Yarn

[Node.js] Installation & Documentation

【Github】 Multi-person Collaboration (2)

【Github】 Basic use (1),

[Git] Code version control – Git Introduction & Basic operation (1)

[Node.js] Building an Automated development environment – Basic introduction, [Tool Preparation], [Start], [Detailed Steps (4)], [Module Processing Tool (5)], [Modular Programming Understanding],

Keep up, step by step! Update below:

Next will continue to learn in detail node.js tool method actual combat: batch rename file method to achieve the duck!! xdm

Improve development efficiency and empower our development efficiency!

Keep up with the pace of progress, forward refueling

Come on!! go~~