Create a basic Node JS Web Site in minutes

In this post I’m going to show you how to get a basic Node JS site up and running in quickly.

I’m assuming for this example you’re running on windows. If you haven’t already, head over to the NodeJS site and download and install the latest stable version

Download Node
Download Node

With Node installed let’s create a basic site to serve our web pages. First create the directory structure as below and create a file called index.html inside the public_html folder

Node structure
Node structure
Edit the index.html file and copy and paste the HTML  below

<!DOCTYPE html>
  <title>Hello Node</title>
  <h1>Page served from Node http-server</h1>
basic html
basic html


Go to the parent of our public_html folder (in this example C:\demos\jitsi) in a command prompt and run

npm init

Just accept all defaults for now by pressing enter at each prompt until the comment has completed


This will create the package.json file in the respective directory

Next let’s install an http server to handle our request as serve up the index.html we created

In the command window we previously opened, make sure we are still in the same directory where we ran our npm init and created out package.json file (in this example C:\demos\jitsi)

Run the command

npm install http-server
Install node http server
Install node http server

Back in the command prompt drop into the public_html directory we created for our index.html

We want Node to run the web server module that we just downloaded, so we need to locate it and copy the directory path onto the clipbaord so that we can use it in the command window. The path will in your node_modules folder under http-server

copy node http-server path

when we have this path on the clipboard go back to the command window and run the command

node C:\demos\jitsi\node_modules\http-server\bin\http-server

I am assuming you have the same directory structure as me here

This will start the http server by default on port 8080.

Node start http-server
Node start http-server

You can now browse the index.html file we created on your browser at using

localhost node server on port 8080
localhost node server on port 8080

2 Replies to “Create a basic Node JS Web Site in minutes”

Leave a Reply

Your email address will not be published. Required fields are marked *