Simple Nodejs WebServer

Node.js is built on Chrome’s V8 JavaScript Engine. It’s useful for a range of applications and it brings JavaScript to the server. Applications written in Node.js are event-driven. For example, if you wanted to create a file, you would provide a callback function to be called upon the file’s successful creation. In this sort of model, your app doesn’t become stuck waiting for events to finish executing.

I hope you have installed nodejs. Then you need to install “forever”

Installing forever

forever, developed by nodejitsu, has functions to create applications that are always running—”forever” running. If the application dies, forever brings it back. It has built-in functionality to monitor processes. It also offers an API you can use to incorporate its features into your own code.

forever can be installed using npm. npm should have been installed as part of Node.js:


Running the app

Create the file index.js with the following contents:


Then run:


Point your browser to or http://localhost. It should display the index.html”

Now we can use forever to manage our application:, instead of running the above command.


To check, open the browser and point it to the or http://localhost. It should display the index.html

Stopping the app is similar: