Node.js Example Application

With Node.js installed on your computer, in this Node.js Tutorial, we shall look into an example Node.js Application and understand some of the basic components that go into making of a Node.js Application.

In this example, we shall create a basic http server listening on a port.

You may use any text editor of your choice to create a Node JavaScript File. Save it with the extension.js .

Create a file with the namenode-js-example.js and copy the following content to it.

Once you have created the file, you may run it using node program from command line interface or terminal.

If you see nothing echoed back to the terminal, it is working fine, and a HTTP server has been started listening at port 8087. Now you may open any of the browser and hit the url http://localhost:8087/  to see our serving responding with html page containing contentNode.js says hello! .

Node.js Example Application

Let us look into the two lines of code that we have written in this example.

Node.js Example

In our subsequent tutorials, we shall learnt about modules in Node.js.

This is just a mere example on how to get started with Node.js. In our next tutorial, we shall learn how to structure your Node.js project.