This time I will show you how to create and restart a nodeJS server, and what are the precautions for creating and restarting a nodeJS server. The following is a practical case, let's take a look.
1: First create a server.js file in the nodejs project, enter the following code
var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }).listen(8888);
:npm install -g nodemon
In this way, the application can be started, and the service will be automatically restarted after the file changes.
Two: ExitThe current terminal command output line command: Ctrl C twice. I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to operate the default parameters of processing functions in ES5 and ES6 environmentsHow to operate $emit in vue Communicate with $on parent-child and sibling componentsThe above is the detailed content of How to create and restart a nodeJS server. For more information, please follow other related articles on the PHP Chinese website!