Just installed nodeJS and NPM and nodesupervisor via Terminal in OS 10.5.8.
I have a server running with:
var http = require("http");
function onRequest(request, response) {
console.log("Request received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World!");
response.end();
}
http.createServer(onRequest).listen(8888);
console.log("Server has started.");
How do I restart the server, without quitting Terminal if the following is updated:
response.write("Hello World, From NodeJS!");
I’ve seen this “^C” used in Terminal, in a NodeJS video TUT.
Also have node supervisor which appears to handle these changes, but when I attempt to use the watch “-w” command(supervisor -w server.js),
on server.js, nothing (“file being watched” or something) is returned, and the supervisor help screen simply reloads.
NPM: 1.0.96
nodeJS: v0.4.11
Ctrl-C is definitely the way to quit node without quitting terminal all together, just like most command-line apps.
A better option for you might be nodemon. It is specifically for restarting node when changes to files are made.
To install:
npm install nodemon -gThen simply execute your app with nodemon instead of node.
nodemon server.js