Wednesday, December 27, 2017

Run a local server using node.js for quick development.

It's a small tip for all the beginners out there. So many times especially when we are developing single page applications or working with git hub. We need to run a local server. Here I am telling you a very easy way to run a localhost at any of your folder.

1.  Install node into your machine. to install Node.js by downloading the installer for your OS from the official site
2. Once installed just got to your favorite location, create a new folder and create an index.html file.
3. I have C:\Users\krishna.mishra\dev\demo
4. Now open your powershell and navigate to this location.
5. Run this command http-server

6. Now you can browse your index.html file running this into browser.


Now you can run all your requests from this local server e.g. reading and writing a local JSON data resource etc. Hope it helps.

For more customization of node server and understanding of node, refer this awesome blog series Node.js Tutorial Series.