Many Options to Run a Local Static Server
While developing applications, learning to use a library or just testing out something quick, you might encounter the need to host your files in a “static” server — meaning that you just need an HTTP server to serve files as-is from a directory — . Nowadays, there are several simple options to get a static server running quickly, and that’s what I’m covering in this article.
For all of the options below that use the command line, I’m assuming that you already entered the folder where your files are located. For example, if your code is in the folder “project”
/
|- project
|- index.html
|- js
|- main.js
You should first enter to your “project” folder in the command line doing something like this:
cd /project
Node Based Servers
If you have NodeJS installed in your machine, there are several packages available through NPM/NPX that you can use. When you install Node, you get NPM and NPX installed as well. If you’re not familiar with NPX, here’s an article I wrote about it explaining it in detail. However, you don’t need to know the details in order to run your any of te options below.