IT Sample: How to Setup Node.js

Setting up the Node.js on Windows

Installation

The official site has installers for Windows and Mac OS, also there are binaries for Linux users. I will describe the installation on Windows, but the general process is the same for other OS. To start, go to the download page of the Node.js. Select the installer you want to download and install it. We will use the 64-bit Windows Installer. You should use the package based on your configuration.

node-js-setup-1

After downloading the file, double-click on it and run the installation wizard.

node-js-setup-2

Pass on the steps and wait while the wizard completes the installation.

node-js-setup-3

node-js-setup-4

That’s all. It is recommended to leave the default settings during installation.

Running the application in a browser

After installing node.js platform, the next step that should do is start node application from your computer. We will create a simple application for demonstration.
Create a folder for your application. I created a project folder on drive C: / inside which created another “app” directory.

node-js-setup-5

Create helloworld.js file inside the “app” directory and write the following code in it:

var http = require('http');
http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(3000);
console.log('Server running at http://localhost:3000/');

node-js-setup-6

The above code is a slightly modified version of the code from the official site, which creates a HTTP web server on your computer. Now we are ready to run our first Node.js application. Open a Node.js command prompt, find it in the Windows Start menu, or use the search:

node-js-setup-7

node-js-setup-8

Command line interface node uses (CLI). Using a command line go to the “app” directory by writing such command:

cd C:\project\app

node-js-setup-9

Next, let’s run helloworld.js file. Run such a command:

node helloworld.js

If all went well, you will see the following message at the command prompt:

node-js-setup-10

Enter such URL in your browser:

http://localhost:3000/

You should see the message “Hello World” in the browser window, which means that everything is working fine.

node-js-setup-11

Thank you for the attention!

The presented sample will help you if you need to deal with an assignment on how to set up node.js. But don’t use our sample as your own paper. If you are lack of motivation to do your homework on your own, you can leave to Assignment.EssayShark.com. We are here to help you achieve new goals in your education. Any of your assignment problems can be solved by our professional expert. You can leave to us a task of any difficulty. We work 24/7 for our customers’ convenience. We will give you the solution in the fastest possible way. Ask us help you and we will do everything possible to satisfy your needs.

If you liked our sample, check out the post on How to Make a Website Using HTML, CSS and JavaScript.

Leave a Reply

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

Customer testimonials

Submit your instructions to the experts without charge.