Node.js is a scripting language available to install not only on Kali Linux but for Windows, FreeBSD, macOS, and other common platforms. Whereas npm is a JavaScript programming language package manager that comes along with Node.js.
With Node.js, the popular JavaScript language has also found its way into server-side programming. Before Node.js, JavaScript was mainly responsible for the frontend and interaction with the visitor. It is quite flexible which means everything from small CLI (command line) tools to complex programs and independent HTTP servers can be developed using Nodejs.
In addition, no additional server is required for a Node.js application, as the application also represents the webserver. The fact that the server and client use the same programming language ( JavaScript ) is certainly another advantage for many users, as the entry barrier is correspondingly low, especially for web developers.
It comes with a number of built-in modules that are available without any further installation. And these modules can be easily installed using NPM, with the help of such modules we Node.js can also connect to a database (e.g. MySQL or MongoDB).
Install Nodejs 14.x and NPM on Kali Linux
There are two ways to install the latest version of node.js on kali Linux one is by adding its repository and the other by downloading the latest Debian packages of Nodejs manually from the official website. Here we will discuss both. You can use the below steps for Ubuntu 20.04, Linux Mint, Elementary OS, MX Linux, Debian, and other similar Linux distros.
Step 1: Add Nodejs 14.x LTS repository
Although there is no need to install the Nodejs repository on Kali Linux, as its packages are already present in the official repo of Kali Linux. However, the version available there is Nodejs 12.x, whereas the current LTS version is 14.x. Thus, those who want the latest version should add the below repo.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Step 2: Run system update
After adding the Nodejs 14 repo on Kali Linux run the system update command to flush the system’s repository cache and let it know that we have recently added something new.
sudo apt update
Step 3: Install Node.JS 14 on Kali Linux
Everything we need to download the latest packages of Node.JS and NPM is in place, now it’s time to run the command to install this Javascript programming language.
sudo apt install nodejs
Step 4: Check Version
Once the installation is completed check the version:
For Nodejs
node -v
For NPM
npm -v
To use the NPM for some package installation you can use it in the following way:
npm install <package name>
For example, we want to install Angular using NPM, the command will be:
For locally:
npm install @angular/cli
Fo Globally: -g syntax refers to the global
npm install -g @angular/cli
Step 5: NPM update command
In the future if you want to update the NPM package manager, then run the following syntax:
npm install -g npm@next
To list all versions of NPM you can use :
npm view npm versions --json
To install some old or specific version of NPM use this command:
npm i -g npm@version
For example, we want to install npm 5.8.0 then the command will be:
npm i -g [email protected]
Step 6: Upgrade npm & Node on Kali Linux
If you already have both NPM and Node on your Kali Linux and want to upgrade them to the possible latest version, the command for that:
npm install -g npm@next
npm install -g node@latest