Node.js HTTP Server


There are quite a number of solutions for running a local HTTP server. You could use Node and install the http-server module. You could also use Express, Jekyll, Rails, etc. Each solution has its own methods and structure.

As a developer, I’ve always wanted to be able to run a HTTP server with little to no dependencies; right inside the directory I’m working in. By “little to no dependencies”, I mean not having to use a specific module or text editor that comes packaged with that feature. You know, just something very simple that has the ability to serve HTML pages so that I don’t have to view them in the browser as “file:///path/to/your/site/index.html”.

Using Node, http-server provides that functionality and is probably the best “no configuration” solution there is. Yet, for my purposes, I don’t want to have to install any npm modules. And I want to have the ability to edit the JavaScript file(s) myself. Thanks to the power of Node, I can now do that.

I created a simple solution that gives the ability to customize a few options. Basically, the solution is this:

  1. For starters, make sure you have Node installed and working.
  2. Drop a single JavaScript file into the root of the directory you’re going to be working in.
  3. Run the HTTP server from the Node command line, and viola!

I have published the solution to my GitHub. Feel free to contribute and report any issues/bugs. I am pretty new to the Node community, and I am honing my JavaScript skills : )