Как удалить node js ubuntu
Перейти к содержимому

Как удалить node js ubuntu

  • автор:

Как удалять node.js в Ubuntu Linux?

У меня на dev компьютере стоит Ubuntu 20.04 и NodeJS 14.xx
Решил обновиться до NodeJS 15.xx (она на днях уже стала доступна, это не LTS версия).

В мире JavaScript я можно сказать новичёк.
Есть не приятное «ощущение» что я, что-то не так делаю:

Установку NodeJS 14 делал согласно инструкциям с официального сайта:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt install -y nodejs

Для того чтобы обновиться на 15-ую версию, решил удалить сначала 14-ую весию:
sudo apt remove nodejs

В результате выполнения команды, получил такие предупреждения:

Reading package lists. Done Building dependency tree Reading state information. Done The following package was automatically installed and is no longer required: libutempter0 Use 'sudo apt autoremove' to remove it. The following packages will be REMOVED: nodejs 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 120 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database . 225795 files and directories currently installed.) Removing nodejs (14.14.0-deb-1nodesource1) . dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/gentle-fs' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cliui/node_modules/strip-ansi' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cliui/node_modules/ansi-regex' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/cliui/node_modules/string-width' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/cliui/node_modules/is-fullwidth-code-point' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/require-main-filename' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/minimist' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/libnpx' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/configstore' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/get-caller-file' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/wrap-ansi/node_modules/strip-ansi' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/wrap-ansi/node_modules/ansi-regex' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/wrap-ansi/node_modules/string-width' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/wrap-ansi/node_modules/is-fullwidth-code-point' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/dot-prop' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/bin-links' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/strip-ansi' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/ansi-regex' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/locate-path' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/p-try' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/p-locate' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/find-up' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/string-width' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/is-fullwidth-code-point' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs/node_modules/p-limit' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/meant' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/yargs-parser/node_modules/camelcase' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/npm-registry-fetch' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/emoji-regex' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/npm-lifecycle' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/npm-audit-report' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_ modules/libcipm' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/docs' not empty so not removed dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/lib' not empty so not removed Processing triggers for man-db (2.9.1-1) . 

NodeJs удалилась. NPM также удалилась (сужу по результату команд: which nodejs which npm)
При этом осталась директория с файликами:

ls /usr/lib/node_modules/npm CHANGELOG.md changelogs CONTRIBUTING.md docs lib LICENSE node_modules npmrc README.md

Вопрос: Как правильно делать удаление (и/или апгрейд на новую версию) NodeJS ?
Спасибо!

  • Вопрос задан более трёх лет назад
  • 3008 просмотров

linux. Удалить node js

Данный материал предоставлен сайтом PacificSky.Ru исключительно в ознакомительных целях. Администрация не несет ответственности за его содержимое.

Удалить NodeJs и все совместимости

    Пошаговое удаление:
    Для того, чтобы удалить NodeJs, достаточно выполнить команду:

sudo apt-get purge nodejs
sudo apt-get autoremove

Данная команда удаляет все зависимости, которые уже не используются ни одним пакетом.

sudo apt-get purge --auto-remove nodejs

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] 

Edit: This is the output from sudo apt-get purge nodejs :

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] 

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
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.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *