Friday , 23 June 2017
Home / Programming / JavaScript / Installing Node.js – Node.js Tutorial for beginners
Installing Node.js
Installing Node.js

Installing Node.js – Node.js Tutorial for beginners

Before we get started, let’s install Node.js. Installing Node.js isn’t very hard actually. You can install Node.js on Windows, Mac and Linux. As of this tutorial, we’ll be installing v0.10.29. However, you can install any version above 0.10.

Installing Node.js

You can download the installers here! Once you download the installer, then you can just run the installer and install Node.js like any other application. It’s really that simple! You do not have to tweak the default installation settings. The default settings will suffice for this tutorial series. Now, you may be wondering, what exactly is being installed?

Node.js Console

You may have already noticed, but you’ll have a program called Node.js. Launch this application and you should see something similar to the image below.

Node.js Console
Node.js Console – Installing Node.js

This little console actually lets you write JavaScript code and execute it on the spot. It’s very simple really. Let’s write some code into it to demonstrate it’s use.

You should see the following outputted onto your console.

Node.js Console - Installing Node.js
Node.js Console – Installing Node.js

Nothing special here. We just create a variable named foo then output it onto the console. You’ll notice that after the output we get undefined outputted as well. You’re doing nothing wrong. The Node.js Console will also output the return value of a function.

So, what is the use of the console?

It’s used mainly for debugging your scripts. To be honest, we won’t be using it at all in this tutorial series.  This console just comes with your installation of Node.js just in case you wanted to run some code really quick without having to restart your application. You won’t find yourself using it that often either. However, it’s still nice to know what else the console can do.  If you were to start writing blocks of code instead of single lines of code, then you’ll start seeing dots in the console. Like so:

Node.js Console - Installing Node.js
Node.js Console – Installing Node.js

Try replicating the image above with you console. The dots you see on your console just means that the console knows that you’re writing a block of code and is waiting for you to close it so it can execute the code inside. If you define a function, then you have to call it after you define it. The console will save the function in memory. If you were to close the console and try running the function, then you’ll get an error telling you the function is not defined. The console is pretty handy for doing some simple JavaScript debugging, but it’s not something we want to use as an editor. We wouldn’t want to use it for creating a real world application. If we were to write code in the console and our system was to crash, then we would lose all our hard work. It’s possible to write code in JavaScript files and have Node.js execute it.

Conclusion

The point of this tutorial was to install Node.js and introduce you to the console. While the console is something we won’t be using at all, it’s still nice to know about it. In the next tutorial, we’ll learn another thing or 2 about Node.js and then I promise we’ll start building real world web applications.

About Jasko Koyn

Check Also

Display Blog Posts

Displaying Blog Posts – Node.js Tutorial for Beginners

In this tutorial, we’ll be displaying blog posts to our visitors. To do this, we …

Leave a Reply

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