1: First create a file in the nodejs project and enter the following code
var http = require("http"); (function(request, response) { (200, {"Content-Type": "text/plain"}); ("Hello World"); (); }).listen(8888);
Then enter the project path under cmd, enter node to start the server, and then enter http://localhost:8888/ in the browser address bar to see the output Hello World on the interface. If we modify the value of Hello World, we will refresh the browser and find that the output has not changed. At this time, we need to manually restart the server to change the output. This is undoubtedly annoying during the development process. It is best to have a script that can monitor all changed files. Once the file is found, restart the service immediately and reload the file you just modified.
Here is a recommendation:nodemon.
First of all, in order to make this command available globally, it is best to install it globally:
npm install -g nodemon
Then go to your project root directory: nodemon
This will enable the application to be started and the service will be automatically restarted after the file changes.
2: Exit the current terminal command and output line command: Ctrl+C twice.
The above method of creating and restarting nodeJS server is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.