How to install and run Node.js on Windows

Node.js is a server side JavaScript software system offer to write full web application based on JavaScript.
Node.js used to compelling server side languages such as PHP, .NET and Ruby into a single compelling package.
Node.js used in many famous industrial packages such as backbeam, Yahoo, ebay and Linkedin.
In this Node.js tutorial i am showing to install node.js on windows, Linux and Mac OS and run first JavaScript in command line using Node.js. Node.js is a standalone non browser JavaScript environment. So you need to have knowledge in JavaScript. Node.js is used to create web servers, scripts and command line tools.
Install and Test Node.js on Windows
Step 1: Download Nodejs for Windows from official website.
If you install Node.js in Windows, just install software like other windows applications.
Step 2: Test your Node.js application
Open any code editor or notepad. Type console.log(‘Application Working’);. Save this file with .js extension (Example: test.js).
Step 3: Open Windows Command Prompt using start -> All Programs -> Accessories -> Command Prompt
Change your command line directory as Desktop using cd Desktop command.
Type node test.js (In this tutorial i am named my file as test.js) and press enter button. Its show Application
working (which added inside console.log(”).
Now it confirm your node,js is running in Windows. If you need Linux based Environment for Node.js in Windows use Cygin.
If you want to run any JavaScript in Node.js, you need to create JavaScript file like this,

var os = require("os");
var msg = 'Your System running under '+ os.platform() +' OS.';

The first one is the require function.

var os = require("os");

When you use a require statement, node searches for what’s called a module. In this case we specify to load os module. Require function return the object which represents all of code available in os module.
Save this example script as os.js file.
Now open your Command Prompt and change the directory to desktop.
Type node os.js

This script pull information from operating system and display in command line.
Try different operating system based utility functions in nodejs.
Try to run JavaScript files using this kind of method to learn Node.js.

Leave a comment

Your email address will not be published. Required fields are marked *