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 headache for me. You can install nodejs and npm without sudo using nvm.
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 headache for me. You can install nodejs and npm without sudo using nvm.
It is better to remove NodeJS and its modules manually because installation leaves a lot of files, links and modules behind and later this creates problems when we reconfigure another version of NodeJS and its modules.
To remove the files, run the following commands:
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/share/man/man1/node*
sudo rm -rf /usr/local/lib/dtrace/node.d
rm -rf ~/.npm
rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf /opt/local/include/node
sudo rm -rf /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*
I have posted a step by step guide with commands on my blog: AMCOS IT Support For Windows and Linux: To completely uninstall node js from Ubuntu.
Videos
As seen from the output of:
sudo apt-get purge nodejs
it is only removing node related packages i.e. relevant packages, nothing more.
On the other hand, when you do:
sudo apt-get purge --auto-remove nodejs
it is essentially doing:
sudo apt-get purge nodejs
sudo apt-get autoremove
and the removal of the gyp, linux-headers-4.4.0-18-generic etc packages are actually triggered by autoremove as they were installed as dependencies and no longer needed by any installed package, presumably because the main package has been removed.
So it is perfectly fine in this context to run:
sudo apt-get purge --auto-remove nodejs
If you are too paranoid, you can do it in two steps: first purge nodejs:
sudo apt-get purge nodejs
and then remove the orphan dependencies (till now, if any):
sudo apt-get autoremove
To remove node js, npm and node_modules from Ubuntu, you need to remove containers also which are at different locations in Ubuntu. These could be as:
/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 have posted the procedure to remove NodeJS on my blog: AMCOS IT Support For Windows and Linux: To completely uninstall node js from Ubuntu.
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_modulesRemove 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'm having trouble starting a new Angular CLI project, keep getting an error like "npm ERR! Unexpected end of JSON input while parsing near '.../angular":"0.7.1","@s" and I have done " npm cache clean --force" multiple times to no avail. I'm thinking of purging Node and NPM and then reinstalling it. How can I achieve that?