Last updated on November 21, 2022
During the front-end development to serve static files such as images, CSS files, and JavaScript files you require web servers. and as of now, you used Apache or Nginx, etc servers to server files. Installing HTTP servers and configuring the environment with Apache and Nginx …etc bundles is a bit difficult for front-end developers.
Fortunately, with node js, front-end developers can easily create HTTP web servers. If you use Nodejs or Nodejs environment then there is a quick zero configuration package for you that works as an HTTP server without writing a single line of code.
Assuming you have Node.js installed on your machine. You need to install the module called http-server
using the following command.
npm install -g http-server
That’s it. Now you can serve any static files and assets using this module. All you have to do is, switch to any folder and run the server using the following command. That folder will act as a server and it will serve static files such as images, CSS files, and JavaScript files.
~/Desktop mkdir demo && cd $_
~/Desktop/demo http-server
Now demo folder will act as the root of the HTTP server.