How to Install and Remove nodejs from Ubuntu

NodeJS is a JavaScript framework that allows us to build network applications with ease. Most of the time we need to install a specific version of nodejs in Ubuntu as per our requirement. So in this article, we will see two things how to install nodejs in ubuntu with a specific version and how to remove nodejs from ubuntu.

Please follow the below simple steps to install and remove nodejs from ubuntu.

Install nodejs with a specific version

First, we'll see how to install nodejs with a specific version. Run below commands to install nodejs in your server.

Refresh your local package index using below command

saveCopyzoom_out_map
sudo apt-get update

Now we'll install nodejs from NodeSource Repository. We'll use curl to add its PPA (Personal Package Archive). So, make sure you have installed curl in your server. If you don't have it then you can install it using the below command.

saveCopyzoom_out_map
sudo apt-get install curl

Now run the following command with sudo to enable NodeSource.

saveCopyzoom_out_map
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -

In the above command, you can change the version according to your requirement. For Ex: setup_18.x

Finally, we are going to install nodejs. Run below command to install

saveCopyzoom_out_map
sudo apt-get install nodejs

Above command not only install nodejs but it also installs npm and other dependencies as well.

once its install successfully you can check its version using following commands

To Check nodejs version run the below command

saveCopyzoom_out_map
node --version

Or

node -v

And to check npm version run the below command

saveCopyzoom_out_map
npm --version //or npm -v

Uninstall NodeJS from Ubuntu

Run below command to uninstall nodejs from ubuntu.

saveCopyzoom_out_map
sudo apt-get remove nodejs

Above commad remove the package but it's configuration files are not remove from your server. If you want to remove both then use below command.

saveCopyzoom_out_map
sudo apt-get purge nodejs

It'll remove package and configuration files.

Run the below command to remove unused files from ubuntu and cleanup the disk space. Its optional command, run this command if you want to cleanup the disk space and remove unused files.

saveCopyzoom_out_map
sudo apt-get autoremove

Bingo!

Finally, we have successfully uninstall nodejs from the Ubuntu and cleanup the disk space.

I hope this article helped you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other handy commands which are not included in the list.

P.S. Do share this note with your team.




Recent Articles
Tags
Newsletter
Chrome Extension
Copyright © 2024 devhooks.in All rights reserved.
Ads OFF toggle_off
wifi_off