Nodejs is awesome and it is requirement if you want to be a JavaScript Developer. By default most Linux systems are shipped with Nodejs but it is usually an old LTS (Long-Term Support)
So how do you install the latest version on your system. Let us see how
Install the Latest Nodejs
To install the default version you can simply do
sudo apt-get install nodejs
However as I said this will install a version 12.x which is not what we need. Hence to install the latest version, you would have to go to their official website and download the latest tar file and then follow along
Step 1:Download Latest version
You can use wget/curl or do a manual download
Step 2: Extraction
Extract using any archiving tool, you can also use tar viatar xv node_.xxx.gz
Step 3: Copy to local library
Make a folder to extract all the files to and then copy them there
sudo mkdir -p /usr/local/lib/nodejs
sudo cp -r . /usr/local/lib/nodejs
Step 4: Add to Path
In order to be able to run node from anywhere from your terminal, you need to add it to your path.
You can do so using two methods. These include linking and exporting it in your .bashrc
file
┌──(rooot㉿kali)-[/usr/local/bin]
└─$ sudo ln -s ../lib/nodejs/bin/node node
┌──(rooot㉿kali)-[/usr/local/bin]
└─$ sudo ln -s ../lib/nodejs/bin/npx npx
┌──(rooot㉿kali)-[/usr/local/bin]
└─$ sudo ln -s ../lib/nodejs/bin/npm npm
If you do ls -ltr
in the above directory you will that it has been linked to that programs
Now you can close the terminal and you will have node on your system.
To check if it was correctly installed and added to your path you can use
node --version
Alternatively you can go to your .bashrc file and export and add it to it as below
export PATH:/usr/local/lib/nodejs/bin:$PATH
I hope you have learnt how to install Nodejs to your kali linux distro
Happy coding
Thanks For Your Time
** Jesus Saves **
** By Jesse E.Agbe(JCharis) **