Node.js and NPM have changed the world by providing ease to developers in their work. Node.js is the tool that enables developers to run their Java script outside of the web browser. Also, NPM is the package manager for the Nodejs modules management because users can use Java on both front-end and back-end web development.
This blog will walk through the methods of installation of Node.js and NPM on Debian 12 using the command line.
What are the Installation Methods of Node.js and NPM on Debian 12?
Different installation methods of Node.js and NPM on Debian 12 are:
All these methods are explained in the step-by-step guide on Debian 12.
Method 1: Install Node.js and NVM Using the Default Repository
The first and easiest method of installing the packages on Debian 12 is by using its default repository. To install Node.js and NVM, execute the below-mentioned command:
$ sudo apt install nodejs npm -y
In the above command, both packages of “nodejs” and “nvm” are installed which can verify by using the command:
$ nodejs --version && npm --version
Method 2: Install Node.js Using the Node Source Repository
Another method of Node.js is by downloading the latest package from the GitHub website using the command:
$ sudo curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt install nodejs -y
Display the version of the installed Nodejs to confirm the execution of the above command:
$ node --version
Method 3: Install Node.js Using the NVM
The NVM is the bash script that enables the users to manage different versions of Node.js. Clone the NVM repository by executing the command:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
The above-executed command will clone the NVM repository from GitHub to the ~/.nvm directory of Debian 12. To install the latest version of a node using the NVM, run the command:
$ nvm install node
To install the LTS version of Node in NVM, use the command:
$ nvm install --lts
To list down the installed version of Node.js on Debian 12 using the NVM:
$ nvm ls
For switching to another version of the NVM, use the command:
$ nvm use 20.4.0
How to Uninstall the Node.js and NVM from Debian 12?
To uninstall the Node.js and NVM from Debian 12, use the remove option of the apt package manager:
$ sudo apt remove nodejs npm -y
To remove the libraries and files associated with the uninstalled packages, use the command:
$ sudo apt auto-remove
This is all about installing Node.js and NPM on Debian 12.
To install the Node.js and NPM on Debian 12, run the “sudo apt install nodejs npm -y” command in the terminal. Other methods of installing them on Debian 12 are by using the NVM or node source repository. All the above-mentioned methods for the installation of Node.js and NPM have been explained in the step-by-step guide in this post.