preface

The author is in the summer vacation between junior and senior years, and now I am working as an intern in front of a medical company in Hangzhou. Before the internship, my learning mode is mainly reading books, watching videos, doing small projects, and then consulting and communicating with outstanding leaders. At present, I have encountered many problems in the internship stage. But these problems are more scattered but difficult to solve the problem of the boring, sometimes inadvertently baidu to solutions, successfully solved the error, but with the passage of time will forget solution, forget the mistake, so, although have upgraded all the way, but it does not go against the front learning and accumulation, So I started this post as a record of difficult and complicated diseases encountered during my practice. ๐Ÿ˜Ž

project

encounter [nodemon] app crashed...Problem, what to do? ๐Ÿ˜ฏ

The error above shows that port 3020 has been occupied, but I did not find the port 3020 already in use on the page. I searched relevant information online. It is said that changing nodemon into Node in package.json file will be effective, but I entered NPM start after modification and restarted for many times. It didn’t work, so I decided to directly find the occupied port of 3020 and shut it down

Solution:

The inputwindow+RKey combination to bring up the command window, entercmd.

Type the commandnetstatย -aonย |ย findstrย "3020"View the running status of the port

As can be seen from the figure above,3020port-listeningPIDfor24740Enter the command againtasklistย |ย findstrย "24740"What process is occupied3020Port, get the following results:

Obviously, port 3020 is occupied by the Node server, so we go directly to the task manager and find the process whose PID is 24740

Click the program, click End process, and then return to its ownVScodeEnd,npm startStart and you will find that the problem is completely resolved and the program has started successfully!

nodemodulesFile too large to delete? ๐Ÿ˜ usegitInstruction quick deletenodemodulesFile ๐Ÿ˜Ž (MAC developers can ignore this, I know you fast… ๐Ÿ˜ถ)

When we practice and write daily projects, we often involve the deletion of nodemodules files. As nodemodules files are too large, it would take a lot of time to delete them either by entering the folder where the project is located or manually deleting them directly in vscode. Then, is there any way to delete them quickly? Of course there is, hee hee, that is the all-purpose Git instruction

  • Install specific environment deletenodemodules

npm install rimraf -g

rimraf node_modules

  • If it iswindowEnvironment, then open firstcmdWindow and enternodemodulesFile folder, enter the following command:

rmdir /s/q node_modules

  • If it isLinuxThe same goes for the environmentcmdWindow, enternodemodulesFolder, enter the following command:

rm -f /node_modules

It is well known that since Nodemodules files are very large and take a long time to delete, it takes a little while to enter instructions.

JavaScript

Map and filter methods

Map and filter methods are often used to filter data in projects. These two methods are a JavaScript wrapper around the loop method, essentially similar to the for loop method, and they do not change the original array, but return a new array, which is very convenient. These two methods can be used together in a project for array traversal and filtering, which is very useful, just be sure to add

return { ... item }Copy the code

Otherwise, the return is empty… ๐Ÿ˜“