Installing Node JS
Hey guys, so hope you had a good week. Let’s crack on something that’s exciting as in doing some hands-on work. Let’s begin this time by installing Node JS. Point your browser to NodeJS Website and please download one of the following versions on to your computer. You’ll be shown with the following two versions:
There’s version 8.9.4 and 9.6.1 at the time of writing this story. The difference between the two is, the one that says LTS, it stands for Long Term Support, and it’s the latest stable version. The one on the right is although the latest version, having all the ground-breaking features, it’s really breaking. Just kidding, it’s with the latest features but it may not be always stable and it’s not meant to be used for production. So, for most of the developers out there, I am going to recommend you to go for the LTS version.
Get the installer edition, go through the installation steps, don’t change the default parameters and just complete the installation. It takes about three minutes for the whole installation to complete and Node JS will be installed.
After installation, we need to make sure if the Node JS is really installed. To check that, you can run a simple command from the command line. You can access the command line in most popular operating systems in the following ways:
Open the Start Menu and type cmd. Press Enter to open the command prompt.
Open your Spotlight Search and type terminal. Press Return to open the terminal application.
Open Terminal in the Applications. You will be able to see the terminal window opened.
Once you open the command prompt or terminal, if you enter the following command:
node -v
This is going to tell the node version that’s been installed in your system. In my PC, it’s something like this:
C:\Users\Praveen>node -v
v8.9.4
So, if you have been a successful installing node, it’s going to return you the version of Node JS that’s been installed in your system. I have got the latest stable version on my computer when writing this article. So, if you do the same in your PC, it might be different. When I wrote one of the pre-requisites in my previous tutorial about knowing a little bit of command line, this is what I meant.
Whenever we need to run an application in node or do something in node, we are going to write a command in the command line using terminal.
Open up a directory of your choice and create a new file called app.js. The only content you should be having inside it should be the following:
console.log(“Hello, World!”);
Once you have saved the file as app.js, you have to run the file using node. To run it, you just need to fire up a command line and run the following command:
node app.js
You should be getting a similar output like this:
node app.js
Hello, World!
Make sure you are in the same directory in the command prompt where the app.js file is residing. You can easily change the directory in command line this way. Let’s consider a scenario where your app.js file is located in a directory named “Node-Stuff” in your Desktop. In Windows, when you open up your command prompt, you will be taken to your profile home directory.
Your “Desktop” is also a directory under your profile home directory, which, in Windows, generally stays at
C:\Users\\Desktop
See the commands that are needed to go to your application directory and run the application:
C:\Users\Praveen>cd Desktop
C:\Users\Praveen\Desktop>cd Node-Stuff
C:\Users\Praveen\Desktop\Node-Stuff>node app.js
Hello, World!
That should have been fairly simple. This is the most simple way to run a node command line application. Also, if you want to know how to navigate through different directories in the command line, you have to use the cd command.
C:\Users\Praveen>cd Desktop
C:\Users\Praveen\Desktop>cd Node-Stuff
C:\Users\Praveen\Desktop\Node-Stuff>cd ..
C:\Users\Praveen\Desktop>
This way, you can traverse between directories in the command prompt. So, to run the Node JS applications that you write, please make sure you run the commands in the folder where you have saved your app.js file and then you can run it with the node command. The other variant of running the node application is not including the file extension of .js as Node JS is smart enough to search for the JavaScript files first. So instead of your node app.js, you can use node app, and that works too.
C:\Users\Praveen\Desktop\Node-Stuff>node app
Hello, World!
See above, it doesn’t use app.js but just app. Cool, isn’t it? It gives the same output.
We have successfully installed Node and we ran our first Node JS application, even though it was a small Hello World application. We’ll be getting to run some advanced Node JS applications in the next articles. Until then, have fun!
Thanks to Praveen Kumar for being our guest writer this week.
We are a leading niche digital & tech recruitment specialist for the North East of England. We Specialise in the acquisition of high-performing technology talent across a variety of IT sectors including Digital & Technology Software Development.
Our ultimate goal is to make a positive impact on every client and candidate we serve - from the initial call and introduction, right up to the final delivery, we want our clients and candidates to feel they have had a beneficial and productive experience.
If you’re looking to start your journey in sourcing talent or find your dream job, you’ll need a passionate, motivated team of experts to guide you. Check out our Jobs page for open vacancies. If interested, contact us or call 0191 620 0123 for a quick chat with our team.
Follow us on our blog, Facebook, LinkedIn, Twitter or Instagram to follow industry news, events, success stories and new blogs releases.
Back to Blog