Hello Devs, it's been a while since I published a post here but it sure feels good to be back on the 'network'. One of my goals (new resolution) in 2021 is to write an article or a couple of articles on any technology I am learning to use or experimenting with as I am a student of full-stack web development. As you might have guessed, the technology I'm learning and currently experimenting with at the time of this writing is node.js. This post is an introduction to node.js in which for the most part I will be talking about how to install and get started with node.js and will also talk on reasons why you should consider using Node.js. So let's started real quick.
What is node.js?
Node.js is an open-source, cross-platform runtime environment to run javascript outside of a web browser. As we might all know javascript since it's conception by Brendan Eitch at Netscape in the 90s was used for mainly for creating dynamic webpages or used for client-side programming, even though Netscape tried a server-side part of JavaScrpt under the trademark of LiveWire (which wasn't successful by the way), it wasn't until 2009 when Ryan Dahl came up with Node.js which introduced non-blocking sockets in JS. Node.js uses Chrome's V8 javascript engine released by The Chromium Project for Google Chrome in 2008.
Installing Node.js
There are a couple of ways to install node.js on your OS of choice, however, I will only cover node.js installation on macOS and windows as they are the two operating systems I use. If your OS differs from the ones mentioned above, you can check the installation guide on node's official website. On macOS, you can easily install node.js using Homebrew (software package management system for macOS operating system and Linux). Once Homebrew is installed, run the following command to install node.js
brew install node
Another way to install node is through the .pkg installer for mac. To install Node.js for Windows, download and install it through the .msi installer file. Alternatively, you can use package managers like Chocolatey and Scoop. That's that about installing Node.js
Just a recommendation for Node beginners. Please download and install the LTS(Long Term Support) version of node for your OS.
To check the version of Node.js installed on your computer, run the command below
node -v
And since Node.js automically installs together with npm, run the following command to check the installed version of npm.
npm -v
Getting started
Now let's look at how to get started with Node. In this section I am going to cover two basic parts which are; How to run node scripts (files) using the command line. To run a node script on the command line or terminal, navigate into the directory containing the file. Say we have a file named node-tutorial.js and what to run it we node, simply type in the following command when your are in the drectory containing the node-tutorial.js file.
node node-tutorials.js
To terminate a node program that is running, it's as easy as using Ctrl-C. Of course they are other methods which are not very necessary for now.
Why Should you use node?
Here, I am going to simply state some reasons why you should consider using node. I would have loved to explain each reason in detail but for the sake of making this post short, I will state the reasons instead, but if you need me to explain any point in detail, do not hesitate to notify me in the comments section. The reasons are;
Node is Lightweight
It is lightening fast.
High performance because of it's asynchronous nature.
It is Easy to Modify and Maintain
Node JS Offers Excellent Scalability.
There are many more reasons why you should consider Node.JS for development but I choose to end here for now. Thanks for reading my post and if you found it useful, please like and share it with your friends and colleagues. Connect with me on twitter @flaacko_flaacko and LinkedIn @Brandon Bawe
Watch out for more post on Node.js from me. But until then, GoodBye and Happy Coding.