How To Install And Test Node.js, And Clone Git Repository On Your Computer
How To Install And Test Node.js, And Clone Git Repository On Your Computer
What is Node.js?
Node.js is a server-side JavaScript framework that is used to create back-end for online applications.
Categorically speaking, Node.js
- Node.js is a free open source server environment which runs on various platforms (Windows, Linux, Unix, Mac OS X, etc., and it uses JavaScript on the server.
What are the advantages of Node.js?
While other languages like PHP or ASP wait for the server to deliver a request to the client before further requests could be sent, Node.js makes use of asynchronous programming.
A common task for a web server can be to open a file on the server and return the content to the client.
Hence, PHP or ASP will handle a request thus:
- Sends the task to the computer's file system.
- Waits while the file system opens and reads the file.
- Returns the content to the client.
- Ready to handle the next request.
- Sends the task to the computer's file system.
- Ready to handle the next request.
- When the file system has opened and read the file, the server returns the content to the client.
Node.js eliminates the waiting, and simply continues with the next request.
Node.js runs single-threaded, non-blocking, asynchronous programming, which is highly memory efficient.
Node.js is equally powerful, and can perform the following tasks:
It can generate dynamic page content
It can create, open, read, write, delete, and close files on the server
It can collect form data
It can add, delete, modify data in your database
So how would you install and test Node.js on your computer or machine. How would you also clone Git repository on your computer.
To install Node.js on your computer,
You'd first need to download Node.js from the official website here.
You'll see the most recent release here. Click on the link that says "Recommended for most users".
At the time of writing this post, this version is version 14.17.5 LTS while the version with the latest features is 16.8.0.
After download, double click the executable to begin installing the program. Keep clicking next, and follow the install prompts to fully install Node.js on your computer.
Configuring the Node.js installation |
Further configurations of Node.js installation |
Click the 'install' button to begin installation |
Node.js installation progress |
Completed Node.js installation |
If you ticked the 'automatically install necessary tools...' option. The process will go ahead to install tools for NodeJs Native modules. These are important tools for NodeJs compilation, C/C++, python and visual studio.
Installing tools for Node.js Native modules |
This installation process opens windows power shell.
Installation of tools for Node.js Native modules in progress |
How to Test Your Node.js Installation
After installation, open your CLI i.e. Command Line Interface. This is the command prompt on windows. With the CLI opened, type npm.
If the installation was successful, you should see a window like this:
Testing if Node.js installation was successful |
Otherwise, you will see a message that the command is not a valid internal or external command.
If your interface is similar to the one above, congratulations! You've successfully installed and tested Node.js
Now that you have it downloaded, you need to extract it to your created folder 'AboutIBM'.
How to Clone a Git Repository
When you clone a repository, you copy the content of the repository. When you clone a repository, you clone the repository to a specific location or directory. To clone a repository, create a folder where you want to clone your repository to, navigate to that directory via your CLI, and use the git command to clone the repository.
Let's clone the IBM Bluemix web app for instance:
The IBM Bluemix web app is located at https://github.com/IBM-Bluemix/bluemix-hello-node
To clone this repository, let's create a folder on our desktop and name it 'AboutIBM'.
We can clone this web app in two ways.
If you have git installed, navigate to the 'AboutIBM' directory, and use the git clone command to clone the repository.
Navigate to the directory using the $ cd command.
Clone using $ git clone repository url.
Hence, we'll have: $cd AboutIBM
$ git clone https://github.com/IBM-Bluemix/bluemix-hello-node
Alternatively, you can clone the repository using the following code:
gh repo clone IBM-Cloud/node-helloworld
If you don't have git installed, you can go directly to github to clone the repository to the created directory. https://github.com/IBM-Cloud/node-helloworld
Click download zip to download the repository to your pc |
Now that you have it downloaded, you need to extract it to your created folder 'AboutIBM'.
To extract the file, you may need a file extractor like WinRAR, WinZip, etc.
Now that you have downloaded, and extracted the repository, you can now open it in your text editor like Sublime Text.
If you don't have Sublime Text already, you can download it here.
Read: Code Editors: Advantages and Types + Best Code Editors for Windows OS, Mac, Linux, Android, Unix
Open Sublime Text and open the folder containing the downloaded repository. In our example, the folder is the node-helloworld-master folder.
Drag this folder to your opened sublime text interface |
IBM Bluemix successfully cloned |
And there we have it. We have successfully installed and tested Node.js, and we have also cloned a git repository, the IBM Bluemix, and have opened that up in our Sublime Text editor.
Post a Comment