Uninstall node js linux

How to remove nodejs from Ubuntu 16.04?

I want to uninstall nodejs and npm and have seen several posts which suggest this is the most common way:

sudo apt-get purge --auto-remove nodejs 

However, this produces a prompt which seems to reference dependencies which, if they were removed, sound like they would cause problems. What is the best way to «undo» the install of nodejs and npm ?

Reading package lists. Done Building dependency tree Reading state information. Done The following packages will be REMOVED: gyp* libboost-python1.58.0* libjs-inherits* libjs-node-uuid* libjs-underscore* libssl-dev* libssl-doc* libuv1* libuv1-dev* linux-headers-4.4.0-18* linux-headers-4.4.0-18-generic* linux-headers-4.4.0-21* linux-headers-4.4.0-21-generic* linux-image-4.4.0-18-generic* linux-image-4.4.0-21-generic* linux-image-extra-4.4.0-18-generic* linux-image-extra-4.4.0-21-generic* linux-signed-image-4.4.0-18-generic* linux-signed-image-4.4.0-21-generic* node-abbrev* node-ansi* node-ansi-color-table* node-archy* node-async* node-block-stream* node-combined-stream* node-cookie-jar* node-delayed-stream* node-forever-agent* node-form-data* node-fstream* node-fstream-ignore* node-github-url-from-git* node-glob* node-graceful-fs* node-gyp* node-inherits* node-ini* node-json-stringify-safe* node-lockfile* node-lru-cache* node-mime* node-minimatch* node-mkdirp* node-mute-stream* node-node-uuid* node-nopt* node-normalize-package-data* node-npmlog* node-once* node-osenv* node-qs* node-read* node-read-package-json* node-request* node-retry* node-rimraf* node-semver* node-sha* node-sigmund* node-slide* node-tar* node-tunnel-agent* node-underscore* node-which* nodejs* nodejs-dev* npm* python-configobj* python-pycurl* python-pyexiv2* python-pyexiv2-doc* 0 to upgrade, 0 to newly install, 72 to remove and 0 not to upgrade. After this operation, 631 MB disk space will be freed. Do you want to continue? [Y/n] 
Reading package lists. Done Building dependency tree Reading state information. Done The following packages were automatically installed and are no longer required: gyp libboost-python1.58.0 libjs-inherits libjs-node-uuid libjs-underscore libssl-dev libssl-doc libuv1 libuv1-dev linux-headers-4.4.0-18 linux-headers-4.4.0-18-generic linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-18-generic linux-image-4.4.0-21-generic linux-image-extra-4.4.0-18-generic linux-image-extra-4.4.0-21-generic linux-signed-image-4.4.0-18-generic linux-signed-image-4.4.0-21-generic python-configobj python-pycurl python-pyexiv2 python-pyexiv2-doc Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: node-abbrev* node-ansi* node-ansi-color-table* node-archy* node-async* node-block-stream* node-combined-stream* node-cookie-jar* node-delayed-stream* node-forever-agent* node-form-data* node-fstream* node-fstream-ignore* node-github-url-from-git* node-glob* node-graceful-fs* node-gyp* node-inherits* node-ini* node-json-stringify-safe* node-lockfile* node-lru-cache* node-mime* node-minimatch* node-mkdirp* node-mute-stream* node-node-uuid* node-nopt* node-normalize-package-data* node-npmlog* node-once* node-osenv* node-qs* node-read* node-read-package-json* node-request* node-retry* node-rimraf* node-semver* node-sha* node-sigmund* node-slide* node-tar* node-tunnel-agent* node-underscore* node-which* nodejs* nodejs-dev* npm* 0 to upgrade, 0 to newly install, 49 to remove and 0 not to upgrade. After this operation, 27.6 MB disk space will be freed. Do you want to continue? [Y/n] 

Источник

Читайте также:  Linux скопировать таблицу разделов

How Can I Completely Uninstall Nodejs, NPM and Node in Ubuntu

Nodejs is an open-source cross platform environment based on JavaScript that makes it easy for the users to create diverse applications and software on the system. NPM stands for Node Package Manager that helps users install Nodejs packages. It also enables users to install any Node.js version on their system and switch to it in seconds. Though both Nodejs and NPM are beneficial in creating diverse applications, with the inclusion of more advanced alternatives, like ExpressJS, ASP.Net, Pyramid and more, it may not be the preferable choice for most users now.

If you have recently installed Nodejs, NPM and Node on Ubuntu, you can uninstall it any time using this article’s guidelines.

Uninstall Nodejs, NPM and Node in Ubuntu

Most Ubuntu users prefer to install Nodejs, NPM and Node from the official Ubuntu repository. So, here we will show you the easiest ways to successfully uninstall Nodejs, NPM and Node from the system, which are as follows:

Method 1: Uninstall from Ubuntu Repository

The Ubuntu users can successfully uninstall Nodejs, NPM and Node associated packages from Ubuntu system through the following command:

Press “Y” at the command terminal to allow apt package manager to completely remove Nodejs, NPM and Node in Ubuntu.

Method 2: Uninstall from Source Directory

The Ubuntu users will find the Nodejs and NPM source directories inside the location “/usr/bin” and it can be confirmed through the following commands:

The users have to remove these directories from the Ubuntu system through the following command to ensure complete uninstallation of Nodejs, NPM and Node.

The users can confirm the uninstallation of Nodejs, NPM and Node from Ubuntu system by executing the following commands:

Conclusion

The complete uninstallation of Nodejs, NPM and Node is simple and it can be done by removing the packages from Ubuntu system through the “apt purge –autoremove” command, or removing the source directories of Nodejs and NPM from the system using the “rm -rf” command. Once the users successfully perform any method, they can then confirm uninstallation through the “-v” command.

About the author

Awais Khan

I’m an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.

Источник

How to Uninstall NodeJS in Ubuntu 22.04

nodejs and ubuntu logos on a green gradient background

Uninstalling NodeJS in Ubuntu can be ineffective if you don’t understand how programs get installed in Ubuntu. The confusion worsens when you are unsure whether to use the uninstall, remove, or purge commands.

This tutorial simplifies NodeJS uninstallation by explaining the workings of package managers, installation directories and the most suitable commands to apply. Lastly, it takes you through practical examples of uninstalling NodeJS in Ubuntu.

Читайте также:  How to disable ipv6 on linux
Table of Contents

The Role of Package Managers in NodeJS installation and Uninstallation in Ubuntu

Installation files are distributed as packages. A package contains the program without its dependencies, which are installed separately. However, that should not worry you because a package manager does the work for you.

The two main types of package managers are dpkg and apt. dpkg is a low-level package manager. It can be less comfortable because you may need to trace packages in the downloader package.

You will likely get a dependency error since most Linux packages rely on others to function, yet dpkg only collects the specified package.

On the other hand, apt (Advanced Package Tool) finds the packages and downloads them or tells you the command to gather the missing dependencies.

apt searches for the packages in the list of repositories stored in the /etc/apt/sources.list or /etc/apt/sources.list.d. If the package URL is unavailable in the configuration file, you can collect them from the target package’s repository and add them to the sources list.

It is worth noting that the apt command has lower-level alternatives called apt-get and apt-cache. The key difference between apt and apt-get is that apt is more user-friendly than apt-get.

Notes/Articles/How to Uninstall NodeJS in Ubuntu/apt-get and apt-cache.png

Where Ubuntu Stores NodeJS binaries

According to the Filesystem Hierarchy Standards (FHS), the binaries of the applications you install are stored in the usr folder. The usr directory has subdirectories like bin, sbin, and local.

The bin subdirectory stores command binaries, for example, the essential commands like cat and ls. It also stores executables’ binaries.

The sbin subdirectory stores commands like adduser used by the system administrator. The local subdirectory mainly contains programs installed from the source code.

Options for Removing NodeJS Binaries

The three typical commands to remove installed binaries are uninstall, remove, and purge.

The uninstall command safely gets rid of a program and its associated files from the hard drive. Certain packages (of programming languages and runtime environments) rely on each other and can only be installed and uninstalled using a specific package manager.

For instance, a NodeJS script could need multiple packages and libraries to work. Its packages are installable through the NodeJS Package Manager (npm).

npm gets installed with NodeJS. It caches information about NodeJS packages.

As a result, you may need to uninstall the package manager when uninstalling NodeJS in Ubuntu. Besides, you could install, run and uninstall NodeJS versions using the Node Version Manager (nvm).

remove is one of the safest commands.

It deletes the package without tampering with the user data. So, you can reinstall the application and still trace your previous data.

Читайте также:  Linux самый распространенный дистрибутив

Lastly, you should use the purge command to eliminate the package and its data.

sudo apt purge [package]bas

The key takeaway is that uninstall, remove, and purge all discard NodeJS and related programs.

The slight difference between the commands depends on your desired extent of file removal or mode of installation. For that reason, this tutorial presents you with multiple options to uninstall NodeJS in Ubuntu.

Step 1: Locate the Binaries

The first step toward uninstalling NodeJS in Ubuntu is finding the folder that houses its binaries. That will enable you to confirm whether NodeJS was uninstalled.

You can use the which or find command to locate NodeJS binaries.

which node find $(echo $PATH | sed 's/:/ /g') -name "node"

Notes/Articles/How to Uninstall NodeJS in Ubuntu/locate node.png

Step 2: Uninstall NodeJS

After locating the node binaries, the next step is to remove them.

Option 1: Remove the Path

The most straightforward and less recommended way to discard NodeJS is manually deleting the node binaries.

Option 2: Uninstall with the apt or apt-get Command

apt and apt-get are the most familiar commands to uninstall NodeJS in Ubuntu.

sudo apt-get remove nodejs

Notes/Articles/How to Uninstall NodeJS in Ubuntu/use remove command.png

Here are their alternatives.

Option 3: Remove All Packages with the purge Command

The purge command clears all node-related packages, including those installed via nvm.

Confirm Installation

Notes/Articles/How to Uninstall NodeJS in Ubuntu/nodejs available.png

Then, uninstall NodeJS using the purge command.

sudo apt-get purge --auto-remove nodejs

Option 4: Uninstall a Particular NodeJS Version

Assume you only want to uninstall a specific NodeJS version. You can specify the version after the nvm command.

Notes/Articles/How to Uninstall NodeJS in Ubuntu/use nvm.png

Option 5: Remove the Source Lists

We can also remove the NodeJS information stored in the /etc/apt/sources.list.d folder.

First, confirm whether NodeJS data exist in the /etc/apt/sources.list.d directory.

Next, remove node from the sources.

rm -rf nodesource.list nodesource.list.distUpgrade

Lastly, update the repositories.

Step 3: Clear the Cache

Uninstalling NodeJS sometimes leaves traces of packages and modules. You can clear the cache by removing npm .

Option 1: Uninstall npm

Option 2: Manually Remove npm

You can delete the hidden npm directory.

Or manually clear npm-related things.

rm -rf /usr/local/,bin,share/man>/npm*

Here, we look into the files installed via source code in the /usr/local directory, then remove NodeJS-related data like npm and node_modules with their binaries.

Notes/Articles/How to Uninstall NodeJS in Ubuntu/clear cache.png

Conclusion

The most straightforward way to uninstall NodeJS in Ubuntu is to use the remove command.

However, since the remove command could leave some cache, it would help to clear the cache using the purge command or manually remove the hidden folders. You can also use the uninstall command with npm .

You can then confirm the uninstallation by checking the installation directories, as guided in this tutorial.

Источник

Оцените статью
Adblock
detector