Sometimes we need to serve static HTML files in localhost. And we really don't want to add any server for a simple HTML file.
Generally, we can right click on the HTML file and can say “open in browser” and it will open the file in your local browser(Chrome, Firefox, Edge, Safari) but it’s actually not exactly what we always want. rather we want something like a simple web server to serve the files from a directory.
http-server
can do exactly that in an easy way.
npm install http-server -g
After installing we can go to our static site directory and can run
http-server
It will serve the directory on localhost 8080 by default.
We can also pass options to that.
Details for the package - npmjs.com/package/http-server
Cheers!