Open In App

Uninstall Node.JS using Linux command line

Last Updated : 02 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

To uninstall Node.js from your Linux system using the command line, you can follow these steps. The specific commands may vary depending on your Linux distribution, so I’ll provide instructions for a few common package managers: APT (Debian/Ubuntu), YUM (Red Hat/CentOS), and DNF (Fedora).

Check if Node is Installed or Not:

Enter the following command to see if node is installed or not

node -v

If a output displaying the version number of the node is shown then node is installed in the system

node-1

To Uninstall Node.js from the Linux

Method: Using Linux Package Managers

Step 1: Enter the following command to remove node

sudo apt remove nodejs

node-4

This will uninstall nodejs from the system

Step 2: Enter the following command to remove npm

sudo apt remove npm

node-5

This will uninstall npm from the system

Step 3: Enter the following command to remove any used files

sudo apt autoremove

node-3

Step 4: Enter the command to check if nodejs is present in the system or not

node -v

node-2

FAQ’s

1. What if I installed Node.js using a different package manager (e.g.nvm)?

If you install node from another package manager let say nvm(Node Version Manager) then you have use the commands of the nvm to uninstall nodejs from the system

Bellow is the command to remove nodejs using nvm

nvm uninstall node

2. What about global npm packages?

Global npm packages are the packages that available anywhere in the system and will be deleted after nodejs is uninstall. To keep the names of the global npm use the following command bellow

 npm list -g --depth=0 > npm-global-packages.txt

It will store the global packages in a file then when you reinstall nodejs it will easier to reinstall the global packages

3. How do I uninstall Node.js if I installed it from the source code?

To uninstall from the source code, Navigate to that directory where you have installed and build the source code and use the following command

sudo make uninstall

4. How do I remove leftover configuration files after uninstalling Node.js?

To remove any leftover configuration files related to Node.js or npm, you can use the following command:

sudo apt-get purge nodejs npm

The purge option not only removes the package but also deletes the associated configuration files.

5. how do I uninstall Node.js on a distribution other than Ubuntu (e.g., CentOS, Fedora, or Debian)?

The specific package manager and commands may vary depending on the Linux distribution. For example, on CentOS and Fedora, you can use yum or dnf like this:

sudo yum remove nodejs npm

On Debian-based systems (e.g., Debian itself or Linux Mint), you can use apt-get like this:

sudo apt-get remove nodejs npm

Conclusion:

Uninstalling Node.js on Linux involves using your package manager to remove the Node.js and npm packages. The exact command and method may vary depending on your Linux distribution and how Node.js was initially installed. Be cautious when uninstalling to ensure that you understand the implications for your system and any global npm packages you may have installed.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads