Home

Run a Local Web Server with Node

No need to mess with Apache or Nginx to run a web server on your local machine. Just use this node command.

This is a separate approach to this article, which shows how to run a local web server with a ruby command.

First, install the command-line utility:

$ npm install http-server -g

Then change to your project's root directory:

$ cd path/to/your/project

And then run the http-server command:

$ http-server .

The dot (.) tells the command you want the document root to be the current directory. You can pass any path here -- for example, instead of changing into the project directory first, you could have written:

$ http-server path/to/your/project

Where path/to/your/project is the actual path to your document root.

You can also specify the port on which to run the server. By default it will run on 8080. Unlike the ruby command, the http-server command requires you to prepend a colon (:) to the port argument:

$ http-server . -p :4567

This example would run the server on port 4567. That means after running this command you can navigate to http://localhost:4567 and see your project.


References:

Let's Connect

Keep Reading

Run a Local Web Server with Ruby

No need to mess with Apache or Nginx to run a web server on your local machine. Just use this ruby command.

Jun 21, 2018

Export Bear Notes to Markdown Files

Bear is one of the best editors out there, but lacks workflows for your content. Here's how to programmatically write Bear notes to local markdown files.

Jun 16, 2021

Generate Random Markdown Files with Node

When writing some script or program that works with markdown files, it's nice to not have to generate them manually. Here's a script to get the job done for you.

Oct 07, 2021