Shopping through STARKUPBD. Happy Shopping

Shopping through STARKUPBD. Happy Shopping

Creating NodeJs server from cmd or from node cmd

Category: Others Post By: Admin Post Date: 24/9/2016

Today , I am going to show you how to create a simple web server using node.js.

1. Download node from here and install it. After That test it from cmd to ensure all is ok or not. 

Test "node -v" To see if Node is installed, type the above on your command line.
Test "npm -v" To see if npm is installed, type the above on your command line.



If your cmd output shows like above then installation ok.

2. For Creating Server we need to download  http-server plugin through node. Installing globally via npm cmd or system cmd:

npm install http-server -g

This will install http-server globally so that it may be run from the command line for any directory. This will help to make any directory as app server. Usually http-server install in user directory > appdata > roaming > npm .if you call http-server this time through cmd then browsing root will be your user root C:\Users\loopcoder.You can test it by browsing http://localhost:8080




Server created successfully. Now Time to create your prefer directory for root browsing. Here i create NodeServer directory in C:\NodeServer. Going to create webroot in this directory so that from cmd command going to this directory and run http-server as like below

C:\NodeServer>http-server




3. Keep any html file in this directory and browse http://localhost:8080/index.html .You get this html view that means node server work perfectly.

Leave Comment
avatar
Anonymous
Comments
X


Twitter