Easiest way to install node.js in linux
Recently i have installed kali linux as a sub-system in windows 10 to test a project i was working on. I was googling to get the easiest way to install node.js in a linux distro. Most of the blogs that came as primary search results were either cumbersome for a starter like me or didn’t work.
I then came across a thread in stack overflow which suggest using NVM(Node Version Manager) to install node.js. It was a very simple process and anybody can follow them to get node.js installed.
Step 1: Install latest version of NVM
(When writing, the latest version is 0.38.0) Check the git hub repo for newest version before installing).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Step 2: Install the desired version of node.js
nvm install <version>Example: nvm install 14.16.1
if you want the latest version of node to be installed
nvm install node
If you want to access node and npm via privilaged ports (The TCP/IP port numbers below 1024 are special in that normal users are not allowed to run servers on them. This is a security feaure, in that if you connect to a service on one of these ports you can be fairly sure that you have the real thing, and not a fake which some hacker has put up for you.) use following code:
n=$(which node)
n=${n%/bin/node}
chmod -R 755 $n/bin/*
sudo cp -r $n/{bin,lib,share} /usr/local
Now check the versions of installed node.js and NPM(Node Package Manager) using following codes:
node -v
npm -v
If you get the newest versions of node.js and NPM you are good to go.
Enjoy coding. Be safe….