I know this question has been asked many times but I couldn't still do it.
So I wrongly installed "node" doing sudo apt-get install node
And later I installed nodejs (v0.10.37). I tried to update to v0.12 with npm but it keeps saying 0.10.37 when I do the nodejs -v
. Also, I can't use the node command since i wrongly installed the other "node thing" before.
I tried all the different commands that the people talks about in all the other answers and I couldn't do it yet.
I think the main problem is that I keep having the wrong node package and installing the nodejs-legacy doesn't work.
Also the npm install
command works and creates the folder with the files but my App still says that the libraries are missing.
sudo apt-get remove nodejs
sudo apt-get remove npm
Then go to /etc/apt/sources.list.d and remove any node list if you have. Then do a
sudo apt-get update
Check for any .npm or .node folder in your home folder and delete those.
If you type
which node
you can see the location of the node. Try which nodejs
and which npm
too.
I would recommend installing node using Node Version Manager(NVM). That saved a lot of head ache for me. Because you can install nodejs and npm without sudo using nvm.
This is better to remove NodeJS and its modules manually because installation leaves a lot of files, links and modules behind and later it create problems while we reconfigure another version of NodeJS and its modules. Run the following commands.
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/node*
and this done.
A step by step guide with commands is at http://amcositsupport.blogspot.in/2016/07/to-completely-uninstall-node-js-from.html
This helped me resolve my problem.
To remove nodejs, npm and node_modules from Ubuntu, you need to remove containers also which are at different locations in Ubuntu.
These could be:
/usr/local/bin/npm
/usr/local/share/man/man1/node
/usr/local/lib/dtrace/node.d
~/.npm
~/.node-gyp
/opt/local/bin/node
opt/local/include/node
/opt/local/lib/node_modules
I did it successfully. So I am sharing the full procedure.
You need to follow the steps that are described here: http://amcositsupport.blogspot.in/2016/07/to-completely-uninstall-node-js-from.html
To completely uninstall node js from Ubuntu
To manually remove node js, npm and node_modules from Ubuntu, you need to do the following steps.
- First of all you need to run the following command from command terminal as sudo.
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
- Remove node or node_modules directories from /usr/local/lib with the help of following command.
sudo rm -rf /usr/local/lib/node*
- Remove node or node_modules directories from /usr/local/include with the help of following command.
sudo rm -rf /usr/local/include/node*
- Remove any node file or dir from /usr/local/bin with the help of following command.
sudo rm -rf /usr/local/bin/node*
- Go to home directory and remove any node or node_modules directory, if exists.
I was crazy delete node and npm and nodejs from my ubuntu 14.04 but with this steps you will remove it...
sudo apt-get uninstall nodejs npm node
sudo apt-get remove nodejs npm node
if you uninstall correctly and it is still there, beffore this check links at bottom...
//this will fine the `/usr/bin` or `/usr/local/bin`
find / -name "node"
// check path of program...
ls -l node
//and remove it
rm -rf /usr/bin/node
More information
Remove - Official website
If you installed via git repository
Try purge nodejs npm and node
For those who installed node.js via the package manager, can just run:
sudo apt-get purge nodejs
Optionally if you have installed it by adding the official NodeSource repository as stated in "Installing Node.js via package manager", do:
sudo rm /etc/apt/sources.list.d/nodesource.list
If you want to clean up npm cache as well:
rm -rf ~/.npm
It is bad practice to try to remove things manually, as it can mess up the package manager, and the opearating system itself.
It bothered me too much while updating node version from 8.1.0 to 10.14.0
here is what worked for me-
- open terminal
(crtl+alt+t)
. - type
which node
, will give path something like /usr/local/bin/node
rm -rf node
, will remove nodenode -v
, no node version ...curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
Note:-if you are getting error like-
node /usr/bin/env: node: No such file or directory
just run-
ln -s /usr/bin/nodejs /usr/bin/node
sorce here
node -v
// will givev10.14.0
Worked for me.
来源:https://stackoverflow.com/questions/32426601/completly-uninstall-nodejs-npm-and-node-in-ubuntu-14-04