We now have a youtube channel. Subscribe!

Node.js | Environment Setup

Node.js | Environment Setup


Hello folks! welcome back to a new section of our tutorial on Node.js. In this section of our tutorial on Node.js, we will be studying about Node.js Environment Setup.

Local Environment Setup

To set up your environment for Node.js, you need the following two softwares available on your computer, Text Editor and Node.js binary installables.

Text Editor

Text Editor is going to be used to type your code. Examples of few editors includes OS Edit command, Windows Notepad, Sublime, Epsilon, Notepad++, EMACS, Brief, Bluefish, Atom, and vim or vi.

Names and versions of text editor can vary on various operating systems. For example, Notepad will be used on Windows, and vim can be used on windows as well as Linux or UNIX.

The files you create with your text editor are called source files and contain the program source codes. The source files for Node.js programs are typically named with the ".js" extension.

Before beginning your programming, make sure that you have one text editor installed and you have enough experience to write a computer program, save it in a file, and then finally execute it.

The Node.js Runtime

The source code written in the source file is JavaScript. The Node.js interpreter is going to be made use of to interpret and execute your JavaScript code.

The Node.js distribution comes as a binary installable for SunOS, Linux, Mac OS X, and Windows OS with the 32-bit (386) and 64-bit (amd64) X86 processor architectures.

The following section will guide you on how to install the Node.js binary distribution on various operating systems.

Download Node.js Archive

Get the latest version of Node.js installable archive file from Node.js Downloads. At the time of writing this article, the following below are the versions available on various OS.

OSArchive name
Windowsnode-v6.3.1-x64.msi
Linuxnode-v6.3.1-linux-x86.tar.gz
Macnode-v6.3.1-darwin-x86.tar.gz
SunOSnode-v6.3.1-sunos-x86.tar.gz

Installation on Windows

Use the MSI file and follow the prompts to install Node.js. By default, the installer uses the distribution in C:\Program Files\nodejs. The installers should set up the C:\Program Files\nodejs\bin directory in window's PATH environment variable. Restart any command prompt that is actively open for the change to take effect.

Installation on UNIX/Linux/Mac OS X, and SunOS

Base on your operating system architecture, download and extract the archive file node-v6.3.1-osname.tar.gz into the /tmp, and then move extracted files into /usr/local/nodejs directory. For example -

$ cd /tmp
$ wget http://nodejs.org/dist/v6.3.1/node-v6.3.1-linux-x64.tar.gz
$ tar xvfz node-v6.3.1-linux-x64.tar.gz
$ mkdir -p /usr/local/nodejs
$ mv node-v6.3.1-linux-x64/* /usr/local/nodejs

Include /usr/local/nodejs/bin directory to the PATH environment variable.

OSOutput
Linuxexport PATH=$PATH:/usr/local/nodejs/bin
Macexport PATH=$PATH:/usr/local/nodejs/bin
FreeBSDexport PATH=$PATH:/usr/local/nodejs/bin

Verify Installation: Executing a File

Create a file, main.js on your machine (Linux or Windows) having the following code -

/* Hello, World! program in node.js */
console.log("Hello, World!")

Now, execute main.js file using the Node.js interpreter to see the result -

$ node main.js

If everything is ok with your installation, this should produce the following output -

Hello, World!


Alright guys! This is where we are going to be rounding up for this tutorial. In our next tutorial guide, we are going to be creating our first Node.js application.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2022 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain