In this article, I am going to explain to you how to set up a simple HTTP web server on local machine using NodeJS. http-server npm package is used to run the web server, Its a single step task for serving static files on browser.
Install http-server npm package
Install the http-server globally on machine using the node package manager (npm) command-line tool, this will allow you to run a web server from anywhere on your computer.
Run the below command on comman line
npm install -g http-server
Start web server
Move to project folder where static files are kept with below command
cd /Desktop/projects/demo/sample-bootstrap
start web server with below command
http-server
Above command will return Urls of hosted files which can be used to check the hosted files on browser.
http server hosted link
Check the hosted files
After running the last command the static files are hosted on the above 2 links provided, Type http://localhost:8080 on your browser URL and you will see your local website.
Conclusion
http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
Click here to find Sample Applications(https://jsonworld.com/demo) on different frameworks of Javascript.
Let me know your thoughts over email pankaj.itdeveloper@gmail.com. I would love to hear them and If you like this article, share with your friends.
This post is originally posted on https://jsonworld.com.