Install Node Js From Source Code

Install Node Js in Windows , Ubuntu and Mac

Node Js – Installation

Here we will study NodeJs installation in the different operating systems and in different ways. Depending upon our development environment we need to install node js from source code or via nvm in windows, mac, and Linux (Including AWS and Google Cloud).

Our first topic will be a focus on how to install node js from source code in Linux, then we will discuss different other methods of installing node js in Windows, Ubuntu, and Mac Operating System

Different Ways of Installing Node Js

There are 4 ways of installing Node JS
  1. Installing Node Js From Source Code
  2. Install Node Js using NVM
  3. Binary Installation. Install Node Js from Binary. Click Here to Install Nodes Js From Binary
  4. Installation from Ubuntu Packages. To install Node Js from Ubuntu Packages click here

Install Node Js From Source Code

Node Js From Source Code can be installed easily in Linux and Mac. Installing node js from source code is not recommended in Windows. But if you still want to do that we will come up with a blog on that.

Here we will see how to install Node Js in Ubuntu and Mac Operating System

Install NodeJs from Source Code- Linux (Ubuntu)

TO INSTALL THE NODE JS FROM Source Code FOLLOW THE BELOW STEPS. Open the Ubuntu terminal and execute the below commands. Your ubuntu system can be on Google Cloud, AWS Cloud, Digital Ocean or even your local machine.

This post focuses completely just on Installation. But if you want to learn Node Js in detail like even creating your own NPM package you should refer this Node Js Complete Guide.

Step 1: Update your apt repository

sudo apt-get update

Step 2: Install build-essentials

sudo apt-get install build-essential openssl libssl-dev pkg-config

Step 3: Change to the src directory

cd /usr/local/src

Step 4: Make a node directory in your src folder

sudo mkdir node

Step 5: Enter the node directory

cd node

Step 6: Download the Source file of Node Js

sudo wget https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz

This URL downloads the specific version of node js. If you want to download the different versions of Node Js Source Code please change the URL accordingly.

NodeJs source code is available in different sources. But the best method will be to download it from nodejs.org. Nodejs.org is the trusted website providing reliable and secure source code of Node Js. The source code of all the versions of Node is available and their link can be found in the website

If you want to experiment with multiple version I will suggest that you should go for the nvm version manager. But if you production-ready application and you are sure of version then please read below points to get the required node js source code for your project.

If you different version requirement please see the list of the available version of Node Js in the link over here https://nodejs.org/en/download/releases/

Step 7: Extract the tar file

sudo tar zxvf node-v8.9.3.tar.gz

Step 8:Enter the Node Js Directory

cd node-v8.9.3

Note: This folder contains raw files that need to be compiled specifically for your particular architecture and kernel. Most source code packages like this come with a bash script called “configure” that will create all these files and set the options for you.

Step 8: Run the configure script

sudo ./configure

Note: If you don’t receive any errors or warnings, the configure script ran successfully.

Step 9: Compile the code to Install Node Js From Source Code

sudo make

make will begin compiling the code. This will take 5-10 minutes or even longer depending on your server resources.

Step 10: Now that make is compiled, install it

sudo make install

Step 11: Check the Node.js and npm version

node –version npm –version

If you see the versions displayed for node and npm, you have successfully compiled Node.js with npm from the source. Since your Node Js is installed, you can now begin installing node modules through npm. Next we will see how to install this in Mac Operating System

But if you want to learn complete Node Js please refer to this link of Node Js. I think this is the best thing available on the internet if you want to explore and learn Node Js better than anyone.

Install NodeJs using NVM

The above method explains how to install node js from source code. But there are scenarios when you need to have multiple versions of Node Js.

There are many such scenarios. Consider you are running two application which requires node 8.9 and other is an old application which requires node 6.1. To handles this we need to use NVM, Node Version Manager.

Installing Node Js Using NVM in Ubuntu

Here, we will install two versions of node js and we will also see which version is available with NVM. Just open your Ubuntu terminal and follow the below instructions

Step 1: Install NVM in Ubuntu

Open Your Ubuntu Terminal and do an update. This command is not necessary but if you have not done an update for along it’s better you do it now.

sudo apt-get update

Step 2: Install build-essentials

Again this is also not necessary. But if NVM or Node Js is the first application in your system, then it’s a high probability that these packages are not installed in your system.

It’s better to execute this command. If everything is installed system will just print the message that it’s already installed.

sudo apt-get install build-essential libssl-dev

Step 3: Getting the NVM Installation script using Curl

Download the curl script of NVM installation by using below command in your ubuntu terminal

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Since we have mentioned a specific version i.e. 0.34 please make a note that, you can modify it to the latest version. Just google which is the latest version of the Node Version Manager (NVM) and change the version number.

Step 4: Run the Script to install Node Js using NVM

Now we will use Bash Command to run the downloaded bash file. The user below command in ubuntu terminal

bash install_nvm.sh

Step 5: Refresh the Profile to get access to Node Version Manager

User the below command so that the current user session is refreshed and you can immediately start using nvm without closing and restarting the new terminal.

source ~/.profile

Step 6: Check and confirm the version of NVM (Node Version Manager)

Well, our NVM is installed, before installing node js using NVM, please confirm whether nvm is installed or not. This can be done by checking the version of the nvm using the below command in your Ubuntu terminal.

You will see the nvm version as the output of this command.

nvm –version

Step 7: Check the Node Js version available with NVM

There could n a number of Node Js versions. NVM supports a set of Node Js version mostly all of them but some of node js version are discarded if they are beta or too outdated.

Use the below command to see list of node js version available with NVM

nvm ls-remote

Step 8: Install the Node Js from NVM

Once NVM is installed it’s very easy to install node js. Just you need to right version of Node Js. Please use below two commands to install the 2 node js version.

But remember the first version becomes the default version of Node Js installed in the computer system. For reference, we will install node js 8.9 and node js 10.11

nvm install 8.9 # this command will install node js 8.9

nvm install 10.11 #this command will install node js 10.11

Step 9: Using the required version of Node Js

Since you have multiple versions of Node Js, it’s important to understand how to use a specific version of node js.

So you open your terminal and want to use node js version 8.9 then you will nvm use 8.9 commands like below or if you want to use node js 10.11 you will execute the second command in your ubuntu terminal

nvm use 8.9 nvm use 10.11

Step 10: Check the Node Js Version and NPM as well

Congrats you have installed multiple versions of Node Js using NVM. But please make sure that you always check which node and NPM you are using while running an application.

Most developers messed up the required node js version for different applications if they are developing side by side. The best way is to always check your node js version using the below command before starting.

node -v

npm -v

Hello Guys, we will be updating this blog to include different methods of installing node js from source code, from nvm, and from packages. And the best part is we will also include methods to install node js different operating systems.

Please comment and share your views in the comment section and we will improve and add new details ASAP. Hey if you want to learn Node Js complete guide you can refer to this link of Node Js Version 3 Complete Course.

Stay happy. Stay Healthy. Keep Social Distancing. Fight COVID-19

What is Node Js

Node js is a javascript runtime built on the Chrome V8 engine. It’s an open-source project which help’s to build a very fast and scalable application.
It has a huge set of the library, modules available contributed by the community which development with Node Js very very easy and fast.
And frontend framework like Angular Js adds to the capability of Nodejs and gives it more than 5 stars.

What is Node Js Source Code

Node js is an open-source code project and its source code is publicly available. The community contributes to the source code and keeps it update with the latest technology and changes.

Users can download the source from as explained above the blog and compile and build it to have your own binary. Free of any sort of malware

Facebook Comments
Show Buttons
Hide Buttons