简体   繁体   中英

Uninstall node from /usr/local/bin/node

I am having a problem uninstalling a package node that does not even exists but still shows up in the path, weird it is or am I dumb... It's contradicting with nodejs and I wana get rid of it and install a fresh node symlink to nodejs so that I have a single source of truth. So far I have tried most the popular package managers.

#tag node vs nodejs linux

durrani@ideapad:~ $ nodejs --version
Command 'nodejs' not found, but can be installed with:
sudo apt install nodejs

durrani@ideapad:~ $ node --version
v12.14.0
durrani@ideapad:~ $ which nodejs
durrani@ideapad:~ $ which node   
/usr/local/bin/node
durrani@ideapad:~ $ type node
node is hashed (/usr/local/bin/node)
durrani@ideapad:~ $ type nodejs
bash: type: nodejs: not found
durrani@ideapad:~ $ sudo apt-get remove node
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package node
durrani@ideapad:~ $ sudo apt-get purge node
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package node
durrani@ideapad:~ $ sudo snap remove node
snap "node" is not installed
durrani@ideapad:~ $ sudo pkcon remove node
Resolving                     [=========================]         Package not found: node
Command failed: This tool could not find the installed package: No packages were found

Got some help from this and run the following:

sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/lib/node_modules/
sudo rm -rf /usr/local/include/node/
sudo rm -rf /usr/local/share/man/man1/node.1

Then I installed nodejs using the official method as mentioned on the Node.js website -> instructions

TL;DR Run the following:
12.16.2 being the LTS version as of today.

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

The final result I got:

durrani@ideapad:~ $ node --version
v12.16.2
durrani@ideapad:~ $ nodejs --version
v12.16.2
durrani@ideapad:~ $ which node
/usr/bin/node
durrani@ideapad:~ $ which nodejs
/usr/bin/nodejs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM